summaryrefslogtreecommitdiff
path: root/source/test/unittests
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2022-12-23 10:58:15 +0100
committerMitya Selivanov <automainint@guattari.tech>2022-12-23 10:58:15 +0100
commit4a16c9bf49bd81ef1d29e8bb7ff013827a73fc8e (patch)
treeca294489b7dceb7e9098525c39ff0881e56ef4d0 /source/test/unittests
parentae1f2013c158e48ae773e74bf00348655e3565ba (diff)
downloadkit-4a16c9bf49bd81ef1d29e8bb7ff013827a73fc8e.zip
[bigint] Signed division
Diffstat (limited to 'source/test/unittests')
-rw-r--r--source/test/unittests/bigint.test.c22
1 files changed, 22 insertions, 0 deletions
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")));