Skip to content

Commit 366f3d6

Browse files
authored
math.big: add test for radix_str() and integer_from_radix() (#24644)
1 parent 2944710 commit 366f3d6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

vlib/math/big/big_test.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,16 @@ fn test_from_and_to_hex() {
719719
}
720720
}
721721

722+
fn test_radix() {
723+
number := '1234567890123456789012345678901234567890'
724+
a := big.integer_from_radix(number, 10)!
725+
for radix in 2 .. 37 {
726+
str := a.radix_str(radix)
727+
b := big.integer_from_radix(str, radix)!
728+
assert b.str() == number
729+
}
730+
}
731+
722732
fn test_str() {
723733
for t in str_test_data {
724734
assert t.value.parse().str() == t.expected

0 commit comments

Comments
 (0)