Skip to content

Commit 58f144b

Browse files
🔍 test(gcd): Test edge case abs(a) === abs(b).
1 parent be87d6f commit 58f144b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/src/Integer/gcd.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,26 @@ test( macro ,
3131
ZZ.from('52310721570994454309603316505452077132504750494613585448247191340916543146521771411345313270814742631')
3232
) ;
3333

34+
function auto ( t , a ) {
35+
t.is( a.abs().toString() , a.gcd(a).toString() ) ;
36+
}
37+
38+
auto.title = (providedTitle, a) => `auto gcd(${a.toString()},${a.toString()}) = ${a.toString()}` ;
39+
40+
test( auto , ZZ.$0() ) ;
41+
test( auto , ZZ.$1() ) ;
42+
test( auto , ZZ.$_1() ) ;
43+
test( auto , ZZ.from(2) ) ;
44+
test( auto , ZZ.from(13280123) ) ;
45+
test( auto ,
46+
ZZ.from('37650526072328171936695291762250209370684337226819795603338569781977444693437332193180866661042770508342415236941382410000000000000000')
47+
) ;
48+
49+
test( auto ,
50+
ZZ.from('-37650526072328171936695291762250209370684337226819795603338569781977444693437332193180866661042770508342415236941382410000000000000000')
51+
) ;
52+
53+
test( macro , ZZ.from(-3) , ZZ.from(3) , ZZ.from(3) ) ;
54+
test( macro , ZZ.from(3) , ZZ.from(-3) , ZZ.from(3) ) ;
55+
3456
// test generated with https://github.com/aureooms-research/gcd

0 commit comments

Comments
 (0)