From 4a16c9bf49bd81ef1d29e8bb7ff013827a73fc8e Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Fri, 23 Dec 2022 10:58:15 +0100 Subject: [bigint] Signed division --- source/test/unittests/bigint.test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/test/unittests/bigint.test.c') diff --git a/source/test/unittests/bigint.test.c b/source/test/unittests/bigint.test.c index 0b45d7b..048bcca 100644 --- a/source/test/unittests/bigint.test.c +++ b/source/test/unittests/bigint.test.c @@ -56,6 +56,28 @@ TEST("bigint base58 mul") { } TEST("bigint div") { + REQUIRE(bi_equal(bi_div(bi_int32(-1), bi_int32(-1)).quotient, + bi_int32(1))); + REQUIRE(bi_equal(bi_div(bi_int32(-1), bi_int32(-1)).remainder, + bi_int32(0))); + REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(2)).quotient, + bi_int32(-2))); + REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(2)).remainder, + bi_int32(1))); + REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-2)).quotient, + bi_int32(-1))); + REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-2)).remainder, + bi_int32(1))); + REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(4)).quotient, + bi_int32(-1))); + REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(4)).remainder, + bi_int32(3))); + REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-4)).quotient, + bi_int32(0))); + REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-4)).remainder, + bi_int32(3))); + + REQUIRE( bi_equal(bi_div(HEX("100"), HEX("10")).quotient, HEX("10"))); -- cgit v1.2.3