Skip to content

Commit

Permalink
Rewrite of BinaryInteger+Random.swift tests (#108) (#110).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Oct 28, 2024
1 parent 0f1737e commit f9a9acf
Show file tree
Hide file tree
Showing 2 changed files with 269 additions and 135 deletions.
37 changes: 37 additions & 0 deletions Sources/TestKit2/Utilities+Integers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,43 @@

import CoreKit

//*============================================================================*
// MARK: * Utilities x Integers
//*============================================================================*

extension BinaryInteger {

//=------------------------------------------------------------------------=
// MARK: Initializers
//=------------------------------------------------------------------------=

@inlinable public static func minLikeSystemsInteger(size: IX) -> Optional<Self> {
guard !size.isZero, Count(size) <= Self.size else {
return nil
}

if Self.isSigned {
return Self(repeating: Bit.one).up(Count(size - 1))

} else {
return Self.zero
}
}

@inlinable public static func maxLikeSystemsInteger(size: IX) -> Optional<Self> {
guard !size.isZero, Count(size) <= Self.size else {
return nil
}

if Self.isSigned {
return Self(repeating: Bit.one).up(Count(size - 1)).toggled()

} else {
return Self(repeating: Bit.one).up(Count(((size)))).toggled()
}
}
}

//*============================================================================*
// MARK: * Utilities x Integers x Edgy
//*============================================================================*
Expand Down
Loading

0 comments on commit f9a9acf

Please sign in to comment.