// Int4Tests+BinaryIntegerTests.swift
// ExtensionsTests
//
// Copyright © 2021 Alexandre H. Saad
// Licensed under Apache License v2.0 with Runtime Library Exception
//

import XCTest
@testable import Extensions

extension Int4Tests {
	func test_initializedClampingSucceeds() {
		// Given
		let min: TestSubject = .init(clamping: -9)
		let max: TestSubject = .init(clamping: 8)

		// Then
		XCTAssertEqual(min, -8)
		XCTAssertEqual(max, 7)
	}
	
	func test_trailingZeroBitCountSucceeds() {
		// Given
		let zero: TestSubject = .init(0b0000)
		let seven: TestSubject = .init(0b0111)

		// Then
		XCTAssertEqual(zero.trailingZeroBitCount, 4)
		XCTAssertEqual(seven.trailingZeroBitCount, 0)
	}
	
	func test_signumSucceeds() {
		// Given
		let negFour: TestSubject = -4
		let zero: TestSubject = 0
		let four: TestSubject = 4
		
		// Then
		XCTAssertEqual(negFour.signum(), -1)
		XCTAssertEqual(zero.signum(), 0)
		XCTAssertEqual(four.signum(), 1)
	}
}
