mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 20:00:09 +00:00
big: Add lcm and its test.
This commit is contained in:
+14
-2
@@ -136,7 +136,7 @@ int_shr_signed = load(l.test_shr_signed, [c_char_p, c_longlong], Res)
|
||||
|
||||
int_factorial = load(l.test_factorial, [c_uint64], Res)
|
||||
int_gcd = load(l.test_gcd, [c_char_p, c_char_p], Res)
|
||||
|
||||
int_lcm = load(l.test_lcm, [c_char_p, c_char_p], Res)
|
||||
|
||||
def test(test_name: "", res: Res, param=[], expected_error = Error.Okay, expected_result = "", radix=16):
|
||||
passed = True
|
||||
@@ -343,6 +343,14 @@ def test_gcd(a = 0, b = 0, expected_error = Error.Okay):
|
||||
|
||||
return test("test_gcd", res, [a, b], expected_error, expected_result)
|
||||
|
||||
def test_lcm(a = 0, b = 0, expected_error = Error.Okay):
|
||||
args = [arg_to_odin(a), arg_to_odin(b)]
|
||||
res = int_lcm(*args)
|
||||
expected_result = None
|
||||
if expected_error == Error.Okay:
|
||||
expected_result = math.lcm(a, b)
|
||||
|
||||
return test("test_lcm", res, [a, b], expected_error, expected_result)
|
||||
|
||||
# TODO(Jeroen): Make sure tests cover edge cases, fast paths, and so on.
|
||||
#
|
||||
@@ -425,6 +433,10 @@ TESTS = {
|
||||
[ 123, 25, ],
|
||||
[ 125, 25, ],
|
||||
],
|
||||
test_lcm: [
|
||||
[ 123, 25, ],
|
||||
[ 125, 25, ],
|
||||
],
|
||||
}
|
||||
|
||||
total_passes = 0
|
||||
@@ -437,7 +449,7 @@ RANDOM_TESTS = [
|
||||
test_add, test_sub, test_mul, test_div,
|
||||
test_log, test_pow, test_sqrt, test_root_n,
|
||||
test_shl_digit, test_shr_digit, test_shl, test_shr_signed,
|
||||
test_gcd,
|
||||
test_gcd, test_lcm,
|
||||
]
|
||||
SKIP_LARGE = [
|
||||
test_pow, test_root_n, # test_gcd,
|
||||
|
||||
Reference in New Issue
Block a user