1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 13:38:12 +00:00

tests: add bn_zero/bn_is_zero

This commit is contained in:
Alex Beregszaszi 2016-08-26 11:54:55 +01:00
parent 97454d9cbc
commit 4eb2bd239c

32
tests.c
View File

@ -123,6 +123,36 @@ START_TEST(test_bignum_equal)
}
END_TEST
START_TEST(test_bignum_zero)
{
bignum256 a;
bignum256 b;
bn_read_be(fromhex("0000000000000000000000000000000000000000000000000000000000000000"), &a);
bn_zero(&b);
ck_assert_int_eq(bn_is_equal(&a, &b), 1);
}
END_TEST
START_TEST(test_bignum_is_zero)
{
bignum256 a;
bn_read_be(fromhex("0000000000000000000000000000000000000000000000000000000000000000"), &a);
ck_assert_int_eq(bn_is_zero(&a), 1);
bn_read_be(fromhex("0000000000000000000000000000000000000000000000000000000000000001"), &a);
ck_assert_int_eq(bn_is_zero(&a), 0);
bn_read_be(fromhex("1000000000000000000000000000000000000000000000000000000000000000"), &a);
ck_assert_int_eq(bn_is_zero(&a), 0);
bn_read_be(fromhex("f000000000000000000000000000000000000000000000000000000000000000"), &a);
ck_assert_int_eq(bn_is_zero(&a), 0);
}
END_TEST
START_TEST(test_bignum_read_le)
{
bignum256 a;
@ -2493,6 +2523,8 @@ Suite *test_suite(void)
tcase_add_test(tc, test_bignum_read_be);
tcase_add_test(tc, test_bignum_write_be);
tcase_add_test(tc, test_bignum_equal);
tcase_add_test(tc, test_bignum_zero);
tcase_add_test(tc, test_bignum_is_zero);
tcase_add_test(tc, test_bignum_read_le);
tcase_add_test(tc, test_bignum_write_le);
tcase_add_test(tc, test_bignum_load_uint32);