From b50e6bd0e4d6b1b1609af86a54f4a78d3adfd06e Mon Sep 17 00:00:00 2001 From: Jonas Quinten Date: Fri, 21 Feb 2025 17:52:44 +0100 Subject: [PATCH] std::math::bigint: Added unit tests for init_with_u128 and init_with_array --- test/unit/stdlib/math/bigint.c3 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unit/stdlib/math/bigint.c3 b/test/unit/stdlib/math/bigint.c3 index 41b21f718..51eb40a6b 100644 --- a/test/unit/stdlib/math/bigint.c3 +++ b/test/unit/stdlib/math/bigint.c3 @@ -1,5 +1,20 @@ module std::math::bigint @test; +fn void test_init_with_u128() +{ + BigInt bi @noinit; + assert(!bi.init_with_u128(uint128.max).is_negative()); +} + +fn void init_with_array() +{ + BigInt bi @noinit; + + assert(bi.init_with_array({0, 0, 0, 1}).equals(bigint::from_int(1))); + + assert("100000000" == bi.init_with_array({1, 0}).to_string_with_radix(16, allocator::temp())); +} + fn void test_parse16() { BigInt bi @noinit;