Skip to content

Commit

Permalink
test: add expect::times test with invalit limits
Browse files Browse the repository at this point in the history
  • Loading branch information
DNKpp committed Jun 17, 2024
1 parent 0d8c88e commit fabfaaa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/mimic++/ExpectationPolicies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace mimicpp::expectation_policies
{
if (m_Max < m_Min)
{
throw std::runtime_error{"min must be less or equal to max."};
throw std::invalid_argument{"min must be less or equal to max."};
}
}

Expand Down
19 changes: 16 additions & 3 deletions test/unit-tests/ExpectationPolicies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ TEST_CASE(
"[expectation][expectation::builder]"
)
{
const std::size_t max = GENERATE(0u, 1u, 2u, 3u, 4u);
const std::size_t min = max + GENERATE(1u, 2u, 3u, 4u);
const std::size_t max = GENERATE(range(0u, 5u));
const std::size_t min = max + GENERATE(range(1u, 5u));

REQUIRE_THROWS_AS(
(expectation_policies::Times{min, max}),
std::runtime_error);
std::invalid_argument);
}

TEST_CASE(
Expand Down Expand Up @@ -1331,6 +1331,19 @@ TEST_CASE(
}
}

TEST_CASE(
"mimicpp::expect::times throws, when invalid limits are provided.",
"[expectation][expectation::factories]"
)
{
const std::size_t max = GENERATE(range(0u, 5u));
const std::size_t min = max + GENERATE(range(1u, 5u));

REQUIRE_THROWS_AS(
expect::times(min, max),
std::invalid_argument);
}

TEST_CASE(
"mimicpp::expect::returns_result_of creates expectation_policies::ReturnsResultOf.",
"[expectation][expectation::factories]"
Expand Down

0 comments on commit fabfaaa

Please sign in to comment.