Skip to content

Commit 0424598

Browse files
committed
Add test set
1 parent 710795a commit 0424598

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/test_big_uints.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,21 @@ auto test_big_uints_shl() -> void
458458
}
459459
}
460460

461+
template <typename T>
462+
void test_digit_counting()
463+
{
464+
constexpr auto max_power {std::is_same<T, boost::decimal::detail::uint256_t>::value ? 77 : 38 };
465+
466+
T current_power {1};
467+
int current_digits {1};
468+
for (int i {}; i <= max_power; ++i)
469+
{
470+
BOOST_TEST_EQ(num_digits(current_power), current_digits);
471+
current_power = current_power * UINT64_C(10);
472+
++current_digits;
473+
}
474+
}
475+
461476
int main()
462477
{
463478
test_big_uints_mul<boost::multiprecision::uint128_t, boost::decimal::detail::uint128 >();
@@ -475,6 +490,9 @@ int main()
475490
test_big_uints_shl<boost::multiprecision::uint128_t, boost::decimal::detail::uint128 >();
476491
test_big_uints_shl<boost::multiprecision::uint256_t, boost::decimal::detail::uint256_t>();
477492

493+
test_digit_counting<boost::decimal::detail::uint128>();
494+
test_digit_counting<boost::decimal::detail::uint256_t>();
495+
478496
return boost::report_errors();
479497
}
480498

0 commit comments

Comments
 (0)