updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2024-08-04 19:12:42 -05:00
parent fa0f648a0b
commit 60b89c5c08
3 changed files with 62 additions and 7 deletions

View File

@ -184,4 +184,54 @@ TEST(utils_common, divide_with_ceiling) {
r = utils::divide_with_ceiling(0, 2);
EXPECT_EQ(0, r);
}
TEST(utils_common, generate_random_between_for_signed_integers) {
static constexpr const auto max_iterations{1000000UL};
for (std::size_t idx = 0U; idx < max_iterations; ++idx) {
auto res = utils::generate_random_between(5, 12);
EXPECT_GE(res, 5);
EXPECT_LE(res, 12);
}
for (std::size_t idx = 0U; idx < max_iterations; ++idx) {
auto res = utils::generate_random_between(-5, 12);
EXPECT_GE(res, -5);
EXPECT_LE(res, 12);
}
}
TEST(utils_common, generate_random_between_for_unsigned_integers) {
static constexpr const auto max_iterations{1000000UL};
for (std::size_t idx = 0U; idx < max_iterations; ++idx) {
auto res = utils::generate_random_between(5U, 12U);
EXPECT_GE(res, 5);
EXPECT_LE(res, 12);
}
}
TEST(utils_common, generate_random_between_throws_error_on_invalid_range) {
EXPECT_THROW(
{
try {
[[maybe_unused]] auto res = utils::generate_random_between(12, 5);
} catch (const std::range_error &e) {
EXPECT_STREQ("end must be greater than begin", e.what());
throw;
}
},
std::range_error);
EXPECT_THROW(
{
try {
[[maybe_unused]] auto res = utils::generate_random_between(12, 12);
} catch (const std::range_error &e) {
EXPECT_STREQ("end must be greater than begin", e.what());
throw;
}
},
std::range_error);
}
} // namespace repertory