tidying up tests

This commit is contained in:
jangko 2023-06-22 22:31:12 +07:00
parent 8c1e43f001
commit 025428d0ae
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
5 changed files with 22 additions and 19 deletions

View File

@ -131,12 +131,6 @@ static:
suite "Wider signed int bitwise coverage":
testBitwise(check, test)
when defined(cpp):
import quicktest, ttmath_compat
func high(T: typedesc[SomeUnsignedInt]): T =
not T(0)
suite "Testing signed int bitwise operations":
test "Shift Left":
var y = 1.u256
@ -180,6 +174,14 @@ suite "Testing signed int bitwise operations":
check c != cast[stint.Int256](b)
check c == a
#[
when defined(cpp):
import quicktest, ttmath_compat
func high(T: typedesc[SomeUnsignedInt]): T =
not T(0)
when defined(cpp):
const
hi = high(int64)
@ -221,3 +223,4 @@ suite "Testing signed int bitwise operations":
mp_z = mp_x shr y
check ttm_z.asSt == mp_z
]#

View File

@ -248,21 +248,21 @@ template testComparison(chk, tst: untyped) =
chkNotIsOdd(chk, "FFFFFFFFFFFFFFFFFA", 256)
tst "operator `isEven`":
chkNotIsOdd(chk, "0", 128)
chkNotIsOdd(chk, "0", 256)
chkIsEven(chk, "0", 128)
chkIsEven(chk, "0", 256)
chkNotIsOdd(chk, "4", 128)
chkNotIsOdd(chk, "4", 256)
chkIsEven(chk, "4", 128)
chkIsEven(chk, "4", 256)
chkNotIsOdd(chk, "FFFFFFFFFFFFFFA", 128)
chkNotIsOdd(chk, "FFFFFFFFFFFFFFFFFA", 256)
chkIsEven(chk, "FFFFFFFFFFFFFFA", 128)
chkIsEven(chk, "FFFFFFFFFFFFFFFFFA", 256)
tst "operator not `isEven`":
chkIsOdd(chk, "1", 128)
chkIsOdd(chk, "1", 256)
chkNotIsEven(chk, "1", 128)
chkNotIsEven(chk, "1", 256)
chkIsOdd(chk, "FFFFFFFFFFFFFFF", 128)
chkIsOdd(chk, "FFFFFFFFFFFFFFFFFF", 256)
chkNotIsEven(chk, "FFFFFFFFFFFFFFF", 128)
chkNotIsEven(chk, "FFFFFFFFFFFFFFFFFF", 256)
tst "isOne":
let x = 1.i128

View File

@ -939,6 +939,7 @@ proc main() =
let z = "115792089237316195423570985008687907853269984665640564039457584007913129639935".u256
let kk = z.truncate(int)
check kk == 9223372036854775807
test "Parsing an unexpected 0x prefix for a decimal string is a CatchableError and not a defect":
let s = "0x123456"

View File

@ -60,7 +60,7 @@ template testdivmod(chk, tst: untyped) =
chkDivMod(chk, "FFFFFFFFFFFFFFFF", "27", "690690690690690", "F", 128)
chkDivMod(chk, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "27", "6906906906906906906906906906906", "15", 128)
#[static:
static:
testdivmod(ctCheck, ctTest)
suite "Wider unsigned int muldiv coverage":
@ -101,7 +101,6 @@ suite "Testing unsigned int division and modulo implementation":
check:
q == 123456789123456789'u64.u256
r == 0'u64.u256
]#
suite "Testing specific failures highlighted by property-based testing":
test "Modulo: 65696211516342324 mod 174261910798982":

View File

@ -7,7 +7,7 @@
#
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import ../stint, unittest, math, test_helpers
import ../stint, unittest, test_helpers
template chkAddMod(chk: untyped, a, b, m, c: string, bits: int) =
chk addmod(fromHex(StUint[bits], a), fromHex(StUint[bits], b), fromHex(StUint[bits], m)) == fromHex(StUint[bits], c)