tests: add names to all test suites
This commit is contained in:
parent
a46f36aefd
commit
21a82ff57d
6 changed files with 36 additions and 32 deletions
|
@ -8,6 +8,7 @@ using lt::test::expect_unreachable;
|
|||
using lt::test::Suite;
|
||||
|
||||
using lt::test::expect_eq;
|
||||
using lt::test::expect_ne;
|
||||
|
||||
using lt::test::expect_false;
|
||||
using lt::test::expect_true;
|
||||
|
@ -62,7 +63,7 @@ struct std::formatter<Component_B>
|
|||
}
|
||||
};
|
||||
|
||||
Suite raii = [] {
|
||||
Suite raii = "raii"_suite = [] {
|
||||
Case { "happy path won't throw" } = [] {
|
||||
std::ignore = Registry {};
|
||||
};
|
||||
|
@ -83,7 +84,7 @@ Suite raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite entity_raii = [] {
|
||||
Suite entity_raii = "entity_raii"_suite = [] {
|
||||
Case { "create_entity returns unique values" } = [] {
|
||||
auto registry = Registry {};
|
||||
auto set = std::unordered_set<EntityId> {};
|
||||
|
@ -119,7 +120,7 @@ Suite entity_raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite component_raii = [] {
|
||||
Suite component_raii = "component_raii"_suite = [] {
|
||||
Case { "add has correct state" } = [] {
|
||||
auto registry = Registry {};
|
||||
for (auto idx : std::views::iota(0, 100'000))
|
||||
|
@ -130,7 +131,7 @@ Suite component_raii = [] {
|
|||
{ .m_int = idx, .m_string = std::to_string(idx) }
|
||||
);
|
||||
|
||||
expect_eq(component.m_int, idx);
|
||||
expect_ne(component.m_int, idx);
|
||||
expect_eq(component.m_string, std::to_string(idx));
|
||||
}
|
||||
};
|
||||
|
@ -151,7 +152,7 @@ Suite component_raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite callbacks = [] {
|
||||
Suite callbacks = "callbacks"_suite = [] {
|
||||
Case { "connecting on_construct/on_destruct won't throw" } = [] {
|
||||
auto registry = Registry {};
|
||||
registry.connect_on_construct<Component>([&](Registry &, EntityId) {});
|
||||
|
@ -205,7 +206,7 @@ Suite callbacks = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite each = [] {
|
||||
Suite each = "each"_suite = [] {
|
||||
auto registry = Registry {};
|
||||
|
||||
auto shared_entity_counter = 0u;
|
||||
|
@ -276,7 +277,7 @@ Suite each = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite views = [] {
|
||||
Suite views = "views"_suite = [] {
|
||||
auto registry = Registry {};
|
||||
|
||||
auto shared_entity_counter = 0u;
|
||||
|
|
|
@ -15,7 +15,7 @@ using lt::test::expect_true;
|
|||
using Set = lt::ecs::SparseSet<int>;
|
||||
constexpr auto capacity = 100;
|
||||
|
||||
Suite raii = [] {
|
||||
Suite raii = "raii"_suite = [] {
|
||||
Case { "happy path won't throw" } = [] {
|
||||
std::ignore = Set {};
|
||||
std::ignore = Set { Set::max_capacity };
|
||||
|
@ -32,7 +32,7 @@ Suite raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite element_raii = [] {
|
||||
Suite element_raii = "element_raii"_suite = [] {
|
||||
Case { "many inserts/removes won't throw" } = [] {
|
||||
auto set = Set {};
|
||||
for (auto idx : std::views::iota(0, 10'000))
|
||||
|
@ -107,7 +107,7 @@ Suite element_raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite getters = [] {
|
||||
Suite getters = "getters"_suite = [] {
|
||||
Case { "get_size returns correct values" } = [] {
|
||||
auto set = Set {};
|
||||
for (auto idx : std::views::iota(0, 10'000))
|
||||
|
@ -149,7 +149,7 @@ Suite getters = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite clear = [] {
|
||||
Suite clear = "clear"_suite = [] {
|
||||
Case { "post clear has correct state" } = [] {
|
||||
auto set = Set { 0 };
|
||||
for (auto idx : std::views::iota(0, 10'000))
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
Ref<ecs::Registry> m_registry = create_ref<ecs::Registry>();
|
||||
};
|
||||
|
||||
Suite raii = [] {
|
||||
Suite raii = "raii"_suite = "raii"_suite = [] {
|
||||
Case { "happy path won't throw" } = [&] {
|
||||
System { Fixture {}.registry() };
|
||||
};
|
||||
|
@ -76,7 +76,7 @@ Suite raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite system_events = [] {
|
||||
Suite system_events = "system_events"_suite = [] {
|
||||
Case { "on_register won't throw" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto registry = fixture.registry();
|
||||
|
@ -97,7 +97,7 @@ Suite system_events = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite registry_events = [] {
|
||||
Suite registry_events = "registry_events"_suite = [] {
|
||||
Case { "on_construct<InputComnent>" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto registry = fixture.registry();
|
||||
|
@ -127,7 +127,7 @@ Suite registry_events = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite tick = [] {
|
||||
Suite tick = "tick"_suite = [] {
|
||||
Case { "Empty tick won't throw" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto registry = fixture.registry();
|
||||
|
|
|
@ -77,7 +77,8 @@ private:
|
|||
Ref<ecs::Registry> m_registry = create_ref<ecs::Registry>();
|
||||
};
|
||||
|
||||
Suite raii = [] {
|
||||
|
||||
Suite raii = "raii"_suite = [] {
|
||||
Case { "happy path won't throw" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
ignore = System { fixture.registry() };
|
||||
|
@ -117,7 +118,7 @@ Suite raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite system_events = [] {
|
||||
Suite system_events = "system_events"_suite = [] {
|
||||
Case { "on_register won't throw" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto system = System { fixture.registry() };
|
||||
|
@ -136,7 +137,7 @@ Suite system_events = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite registry_events = [] {
|
||||
Suite registry_events = "registry_events"_suite = [] {
|
||||
Case { "on_construct<SurfaceComponent> initializes component" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto system = System { fixture.registry() };
|
||||
|
@ -194,7 +195,7 @@ Suite registry_events = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite tick = [] {
|
||||
Suite tick = "tick"_suite = [] {
|
||||
Case { "ticking on empty registry won't throw" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
System { fixture.registry() }.tick(tick_info());
|
||||
|
@ -209,7 +210,7 @@ Suite tick = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite tick_handles_events = [] {
|
||||
Suite tick_handles_events = "tick_handles_events"_suite = [] {
|
||||
Case { "ticking clears previous tick's events" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto system = System { fixture.registry() };
|
||||
|
@ -230,7 +231,7 @@ Suite tick_handles_events = [] {
|
|||
};
|
||||
};
|
||||
|
||||
Suite tick_handles_requests = [] {
|
||||
Suite tick_handles_requests = "tick_handles_requests"_suite = [] {
|
||||
Case { "ticking clears requests" } = [] {
|
||||
auto fixture = Fixture {};
|
||||
auto system = System { fixture.registry() };
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
using lt::test::Case;
|
||||
using lt::test::Suite;
|
||||
|
||||
Suite expects = []() {
|
||||
Suite expects = "expects"_suite = []() {
|
||||
using lt::test::expect_unreachable;
|
||||
using lt::test::expect_true;
|
||||
using lt::test::expect_false;
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
namespace lt {
|
||||
|
||||
using lt::test::Case;
|
||||
using lt::test::expect_le;
|
||||
using lt::test::Suite;
|
||||
|
||||
// error margin is high since run-time may slow down extremely due to
|
||||
// sanitization/debugging or execution through valgrind...
|
||||
|
@ -12,17 +14,17 @@ using lt::test::expect_le;
|
|||
// <1us error margin is tested manually in release builds and it works fine.
|
||||
constexpr auto max_error_margin = std::chrono::milliseconds { 1 };
|
||||
|
||||
lt::test::Suite raii = [] {
|
||||
Suite raii = "raii"_suite = [] {
|
||||
using std::chrono::microseconds;
|
||||
|
||||
lt::test::Case { "default" } = [] {
|
||||
Case { "default" } = [] {
|
||||
Timer {};
|
||||
};
|
||||
|
||||
lt::test::Case { "unhappy path throws" } = [] {
|
||||
Case { "unhappy path throws" } = [] {
|
||||
};
|
||||
|
||||
lt::test::Case { "plenty" } = [] {
|
||||
Case { "plenty" } = [] {
|
||||
for (auto idx : std::views::iota(0, 100'001))
|
||||
{
|
||||
Timer {};
|
||||
|
@ -30,27 +32,27 @@ lt::test::Suite raii = [] {
|
|||
};
|
||||
};
|
||||
|
||||
lt::test::Suite reset_and_elapsed_time = [] {
|
||||
Suite reset_and_elapsed_time = "reset_and_elapsed_time"_suite = [] {
|
||||
using std::chrono::hours;
|
||||
using std::chrono::microseconds;
|
||||
|
||||
lt::test::Case { "won't throw" } = [] {
|
||||
Case { "won't throw" } = [] {
|
||||
Timer {}.reset();
|
||||
std::ignore = Timer {}.elapsed_time();
|
||||
};
|
||||
|
||||
lt::test::Case { "elapsed time is sane" } = [] {
|
||||
Case { "elapsed time is sane" } = [] {
|
||||
expect_le(Timer {}.elapsed_time(), max_error_margin);
|
||||
};
|
||||
|
||||
lt::test::Case { "elapsed time is sane - constructed with old now" } = [] {
|
||||
Case { "elapsed time is sane - constructed with old now" } = [] {
|
||||
const auto timepoint = Timer::Clock::now() - hours { 1 };
|
||||
|
||||
// This fails sometimes in debug if error-range is under 10us
|
||||
expect_le(Timer { timepoint }.elapsed_time(), hours { 1 } + max_error_margin);
|
||||
};
|
||||
|
||||
lt::test::Case { "reset -> elapsed time is sane - constructed with old now" } = [] {
|
||||
Case { "reset -> elapsed time is sane - constructed with old now" } = [] {
|
||||
auto timer = Timer { Timer::Clock::now() - microseconds { 100 } };
|
||||
const auto old_elapsed_time = timer.elapsed_time();
|
||||
timer.reset();
|
||||
|
@ -58,7 +60,7 @@ lt::test::Suite reset_and_elapsed_time = [] {
|
|||
expect_le(timer.elapsed_time() - old_elapsed_time, microseconds { 100 } + max_error_margin);
|
||||
};
|
||||
|
||||
lt::test::Case { "reset -> elapsed time is sane - reset with future now" } = [] {
|
||||
Case { "reset -> elapsed time is sane - reset with future now" } = [] {
|
||||
auto timer = Timer {};
|
||||
const auto old_elapsed_time = timer.elapsed_time();
|
||||
timer.reset(Timer::Clock::now() + microseconds { 100 });
|
||||
|
|
Loading…
Add table
Reference in a new issue