Skip to content

math.big: add test for radix_str() and integer_from_radix() #24644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vlib/math/big/big_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,16 @@ fn test_from_and_to_hex() {
}
}

fn test_radix() {
number := '1234567890123456789012345678901234567890'
a := big.integer_from_radix(number, 10)!
for radix in 2 .. 37 {
str := a.radix_str(radix)
b := big.integer_from_radix(str, radix)!
assert b.str() == number
}
}

fn test_str() {
for t in str_test_data {
assert t.value.parse().str() == t.expected
Expand Down
Loading