Skip to content

Commit

Permalink
Fix to string tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ioxid committed Nov 13, 2024
1 parent 1728091 commit 5255db0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crypto3/libs/multiprecision/test/big_integer_modular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,44 @@ BOOST_AUTO_TEST_CASE(construct_constexpr) {
BOOST_AUTO_TEST_CASE(construct_modular_ct_trivial_montgomery) {
static constexpr auto mod = 0x3_big_integer64;
auto_modular_big_integer<mod> a = auto_modular_big_integer<mod>(0x5_big_integer64);
BOOST_CHECK_EQUAL(a.str(), "0x2");
BOOST_CHECK_EQUAL(a.str(), "0x2 mod 0x3");
}

BOOST_AUTO_TEST_CASE(construct_modular_rt_trivial_montgomery) {
modular_big_integer_rt<64> a{0x5_big_integer64, 0x3_big_integer64};
BOOST_CHECK_EQUAL(a.str(), "0x2");
BOOST_CHECK_EQUAL(a.str(), "0x2 mod 0x3");
}

BOOST_AUTO_TEST_CASE(construct_modular_ct_small_montgomery) {
static constexpr auto mod = 0x79_big_integer64;
auto_modular_big_integer<mod> a = auto_modular_big_integer<mod>(0x1234_big_integer64);
BOOST_CHECK_EQUAL(a.str(), "0x3E");
BOOST_CHECK_EQUAL(a.str(), "0x3E mod 0x79");
}

BOOST_AUTO_TEST_CASE(construct_modular_rt_small_montgomery) {
modular_big_integer_rt<64> a{0x1234_big_integer64, 0x79_big_integer64};
BOOST_CHECK_EQUAL(a.str(), "0x3E");
BOOST_CHECK_EQUAL(a.str(), "0x3E mod 0x79");
}

BOOST_AUTO_TEST_CASE(construct_modular_ct_small) {
static constexpr auto mod = 0x78_big_integer64;
auto_modular_big_integer<mod> a = auto_modular_big_integer<mod>(0x1234_big_integer64);
BOOST_CHECK_EQUAL(a.str(), "0x64");
BOOST_CHECK_EQUAL(a.str(), "0x64 mod 0x78");
}

BOOST_AUTO_TEST_CASE(construct_modular_rt_small) {
modular_big_integer_rt<64> a{0x1234_big_integer64, 0x78_big_integer64};
BOOST_CHECK_EQUAL(a.str(), "0x64");
BOOST_CHECK_EQUAL(a.str(), "0x64 mod 0x78");
}

BOOST_AUTO_TEST_CASE(to_string_trivial) {
BOOST_CHECK_EQUAL((static_cast<modular_big_int>(0x1_big_integer64)).str(), "0x1");
BOOST_CHECK_EQUAL((static_cast<modular_big_int>(0x1_big_integer64)).str(),
"0x1 mod 0x123456789ABCDEF");
}

BOOST_AUTO_TEST_CASE(to_string_small) {
BOOST_CHECK_EQUAL((static_cast<modular_big_int>(0x20_big_integer64)).str(), "0x20");
BOOST_CHECK_EQUAL((static_cast<modular_big_int>(0x20_big_integer64)).str(),
"0x20 mod 0x123456789ABCDEF");
}

BOOST_AUTO_TEST_CASE(ops) {
Expand Down

0 comments on commit 5255db0

Please sign in to comment.