Skip to content

Commit

Permalink
Cleanup of 2-by-1 division tests (#110).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Nov 10, 2024
1 parent a8ee713 commit 1cd09a7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Tests/UltimathnumTests/BinaryInteger+Division.swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ import TestKit
func whereIs<T>(_ type: T.Type) throws where T: SystemsIntegerAsSigned {
for _ in 0 ..< conditional(debug: 32, release: 256) {
let divisor = Nonzero(T.random(in: T.negatives)!)
let quotient = T.max
let remainder = divisor.value + 1
let quotient = T.min
let remainder = T(-1) - divisor.value
var dividend = divisor.value.multiplication(quotient).plus(Doublet(remainder))
var division = T.division(dividend.value, by: divisor) as Fallible<Division<T, T>>

Expand All @@ -612,19 +612,19 @@ import TestKit
try #require(division.value.quotient == quotient )
try #require(division.value.remainder == remainder)

dividend = dividend.value.minus(Doublet(T.lsb))
dividend = dividend.value.plus(Doublet(T.lsb))
division = T.division(dividend.value, by: divisor)

try #require(dividend.error == false)
try #require(division.error == true)
try #require(division.value.quotient == T.min)
try #require(division.value.quotient == T.max)
try #require(division.value.remainder .isZero)
}
}
}

@Test(
"BinaryInteger/division/edge-cases/2-by-1: edges of (+) by (-)",
"BinaryInteger/division/edge-cases/2-by-1: edges of (-) by (-)",
Tag.List.tags(.generic, .important, .random),
arguments: typesAsSystemsIntegerAsSigned, fuzzers
) func edgesOfNegativeByNegative(
Expand All @@ -635,8 +635,8 @@ import TestKit
func whereIs<T>(_ type: T.Type) throws where T: SystemsIntegerAsSigned {
for _ in 0 ..< conditional(debug: 32, release: 256) {
let divisor = Nonzero(T.random(in: T.negatives)!)
let quotient = T.min
let remainder = T(-1) - divisor.value
let quotient = T.max
let remainder = divisor.value + 1
var dividend = divisor.value.multiplication(quotient).plus(Doublet(remainder))
var division = T.division(dividend.value, by: divisor) as Fallible<Division<T, T>>

Expand All @@ -645,12 +645,12 @@ import TestKit
try #require(division.value.quotient == quotient )
try #require(division.value.remainder == remainder)

dividend = dividend.value.plus(Doublet(T.lsb))
dividend = dividend.value.minus(Doublet(T.lsb))
division = T.division(dividend.value, by: divisor)

try #require(dividend.error == false)
try #require(division.error == true)
try #require(division.value.quotient == T.max)
try #require(division.value.quotient == T.min)
try #require(division.value.remainder .isZero)
}
}
Expand Down

0 comments on commit 1cd09a7

Please sign in to comment.