Skip to content

Commit

Permalink
refactor: rename RuntimeTimes to Times
Browse files Browse the repository at this point in the history
  • Loading branch information
DNKpp committed Jun 17, 2024
1 parent 78f1471 commit 2a21b74
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
32 changes: 16 additions & 16 deletions include/mimic++/ExpectationPolicies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ namespace mimicpp::expectation_policies
}
};

class RuntimeTimes
class Times
{
public:
[[nodiscard]]
constexpr explicit RuntimeTimes(const std::size_t min, const std::size_t max)
constexpr explicit Times(const std::size_t min, const std::size_t max)
: m_Min{min},
m_Max{max}
{
Expand Down Expand Up @@ -132,12 +132,12 @@ namespace mimicpp::expectation_policies
};

class InitTimes
: public RuntimeTimes
: public Times
{
public:
[[nodiscard]]
consteval InitTimes() noexcept
: RuntimeTimes{1u, 1u}
: Times{1u, 1u}
{
}
};
Expand Down Expand Up @@ -495,7 +495,7 @@ namespace mimicpp::expect
[[nodiscard]]
consteval auto times() noexcept
{
return expectation_policies::RuntimeTimes{
return expectation_policies::Times{

Check failure on line 498 in include/mimic++/ExpectationPolicies.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/mimic++/ExpectationPolicies.hpp#L498

Exception thrown in function declared not to throw exceptions.
min,
max
};
Expand All @@ -505,7 +505,7 @@ namespace mimicpp::expect
[[nodiscard]]
consteval auto at_least() noexcept
{
return expectation_policies::RuntimeTimes{
return expectation_policies::Times{
min,
std::numeric_limits<std::size_t>::max()
};
Expand All @@ -515,7 +515,7 @@ namespace mimicpp::expect
[[nodiscard]]
consteval auto at_most() noexcept
{
return expectation_policies::RuntimeTimes{
return expectation_policies::Times{
0u,
max
};
Expand All @@ -524,7 +524,7 @@ namespace mimicpp::expect
[[nodiscard]]
consteval auto once() noexcept
{
return expectation_policies::RuntimeTimes{
return expectation_policies::Times{
1u,
1u
};
Expand All @@ -533,34 +533,34 @@ namespace mimicpp::expect
[[nodiscard]]
consteval auto twice() noexcept
{
return expectation_policies::RuntimeTimes{
return expectation_policies::Times{
2u,
2u
};
}

[[nodiscard]]
constexpr expectation_policies::RuntimeTimes times(const std::size_t min, const std::size_t max)
constexpr expectation_policies::Times times(const std::size_t min, const std::size_t max)
{
return expectation_policies::RuntimeTimes{min, max};
return expectation_policies::Times{min, max};

Check warning on line 545 in include/mimic++/ExpectationPolicies.hpp

View check run for this annotation

Codecov / codecov/patch

include/mimic++/ExpectationPolicies.hpp#L545

Added line #L545 was not covered by tests
}

[[nodiscard]]
constexpr expectation_policies::RuntimeTimes times(const std::size_t exactly) noexcept
constexpr expectation_policies::Times times(const std::size_t exactly) noexcept
{
return times(exactly, exactly);
}

[[nodiscard]]
constexpr expectation_policies::RuntimeTimes at_least(const std::size_t min) noexcept
constexpr expectation_policies::Times at_least(const std::size_t min) noexcept
{
return expectation_policies::RuntimeTimes{min, std::numeric_limits<std::size_t>::max()};
return expectation_policies::Times{min, std::numeric_limits<std::size_t>::max()};

Check failure on line 557 in include/mimic++/ExpectationPolicies.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/mimic++/ExpectationPolicies.hpp#L557

Exception thrown in function declared not to throw exceptions.

Check warning on line 557 in include/mimic++/ExpectationPolicies.hpp

View check run for this annotation

Codecov / codecov/patch

include/mimic++/ExpectationPolicies.hpp#L557

Added line #L557 was not covered by tests
}

[[nodiscard]]
constexpr expectation_policies::RuntimeTimes at_most(const std::size_t max) noexcept
constexpr expectation_policies::Times at_most(const std::size_t max) noexcept
{
return expectation_policies::RuntimeTimes{0u, max};
return expectation_policies::Times{0u, max};

Check failure on line 563 in include/mimic++/ExpectationPolicies.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/mimic++/ExpectationPolicies.hpp#L563

Exception thrown in function declared not to throw exceptions.

Check warning on line 563 in include/mimic++/ExpectationPolicies.hpp

View check run for this annotation

Codecov / codecov/patch

include/mimic++/ExpectationPolicies.hpp#L563

Added line #L563 was not covered by tests
}

namespace detail
Expand Down
32 changes: 16 additions & 16 deletions test/unit-tests/ExpectationPolicies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace mimicpp;
TEMPLATE_TEST_CASE(
"Given types satisfy mimicpp::times_policy concept.",
"[expectation][expectation::builder]",
expectation_policies::RuntimeTimes,
expectation_policies::Times,
expectation_policies::InitTimes
)
{
Expand Down Expand Up @@ -96,7 +96,7 @@ TEST_CASE(
const std::size_t min = GENERATE(0u, 1u, 2u, 3u, 4u);
const std::size_t max = min + GENERATE(0u, 1u, 2u, 3u, 4u);

expectation_policies::RuntimeTimes policy{min, max};
expectation_policies::Times policy{min, max};

for ([[maybe_unused]] auto i : std::views::iota(0u, min))
{
Expand All @@ -121,20 +121,20 @@ TEST_CASE(
}

TEST_CASE(
"expectation_policies::RuntimeTimes does throw, when invalid config is given.",
"expectation_policies::Times does throw, when invalid config is given.",
"[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);

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

TEST_CASE(
"both, expectation_policies::Times and expectation_policies::RuntimeTimes use detail::describe_times_state for their description.",
"both, expectation_policies::Times and expectation_policies::Times use detail::describe_times_state for their description.",
"[expectation][expectation::builder]"
)
{
Expand Down Expand Up @@ -1133,7 +1133,7 @@ TEST_CASE(
{
SECTION("times with binary limits.")
{
expectation_policies::RuntimeTimes times = expect::times<2, 5>();
expectation_policies::Times times = expect::times<2, 5>();
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1153,7 +1153,7 @@ TEST_CASE(

SECTION("times with unary limits.")
{
expectation_policies::RuntimeTimes times = expect::times<3>();
expectation_policies::Times times = expect::times<3>();
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1171,7 +1171,7 @@ TEST_CASE(

SECTION("at_most")
{
expectation_policies::RuntimeTimes times = expect::at_most<3>();
expectation_policies::Times times = expect::at_most<3>();
REQUIRE(times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1189,7 +1189,7 @@ TEST_CASE(

SECTION("at_least")
{
expectation_policies::RuntimeTimes times = expect::at_least<3>();
expectation_policies::Times times = expect::at_least<3>();
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1215,7 +1215,7 @@ TEST_CASE(

SECTION("once")
{
expectation_policies::RuntimeTimes times = expect::once();
expectation_policies::Times times = expect::once();
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1227,7 +1227,7 @@ TEST_CASE(

SECTION("twice")
{
expectation_policies::RuntimeTimes times = expect::twice();
expectation_policies::Times times = expect::twice();
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1244,13 +1244,13 @@ TEST_CASE(
}

TEST_CASE(
"mimicpp::expect::times and similar factories with runtime limits create expectation_policies::RuntimeTimes.",
"mimicpp::expect::times and similar factories with runtime limits create expectation_policies::Times.",
"[expectation][expectation::factories]"
)
{
SECTION("times with binary limits.")
{
expectation_policies::RuntimeTimes times = expect::times(2, 5);
expectation_policies::Times times = expect::times(2, 5);
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1270,7 +1270,7 @@ TEST_CASE(

SECTION("times with unary limits.")
{
expectation_policies::RuntimeTimes times = expect::times(3);
expectation_policies::Times times = expect::times(3);
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1288,7 +1288,7 @@ TEST_CASE(

SECTION("at_most")
{
expectation_policies::RuntimeTimes times = expect::at_most(3);
expectation_policies::Times times = expect::at_most(3);
REQUIRE(times.is_satisfied());
REQUIRE(times.is_applicable());

Expand All @@ -1306,7 +1306,7 @@ TEST_CASE(

SECTION("at_least")
{
expectation_policies::RuntimeTimes times = expect::at_least(3);
expectation_policies::Times times = expect::at_least(3);
REQUIRE(!times.is_satisfied());
REQUIRE(times.is_applicable());

Expand Down

0 comments on commit 2a21b74

Please sign in to comment.