Compare commits
No commits in common. "3ad8fc6d2130bb05d43485e96defe35028f314af" and "02053fb3835a9aca61881395d358deeaaf808eaf" have entirely different histories.
3ad8fc6d21
...
02053fb383
2 changed files with 24 additions and 23 deletions
|
@ -37,7 +37,7 @@ TEST_CASE("Entity #0 should be reserved and never used", "[test]")
|
|||
REQUIRE_FALSE(w.is_alive(0));
|
||||
}
|
||||
|
||||
struct ChosenOne
|
||||
struct ChoosenOne
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -48,7 +48,7 @@ TEST_CASE("Entity shouldn't have a component that wasn't attached to it",
|
|||
|
||||
auto e = w.make_entity();
|
||||
|
||||
REQUIRE_FALSE(w.has<ChosenOne>(e));
|
||||
REQUIRE_FALSE(w.has<ChoosenOne>(e));
|
||||
}
|
||||
|
||||
TEST_CASE("Attempt of getting non-owned component should throw", "[test]")
|
||||
|
@ -57,7 +57,7 @@ TEST_CASE("Attempt of getting non-owned component should throw", "[test]")
|
|||
|
||||
auto e = w.make_entity();
|
||||
|
||||
REQUIRE_THROWS(w.get<ChosenOne>(e));
|
||||
REQUIRE_THROWS(w.get<ChoosenOne>(e));
|
||||
}
|
||||
|
||||
TEST_CASE("Attach a simple component to an entity and verify it is correctly "
|
||||
|
@ -68,12 +68,12 @@ TEST_CASE("Attach a simple component to an entity and verify it is correctly "
|
|||
|
||||
auto e1 = w.make_entity();
|
||||
|
||||
w.set(e1, ChosenOne{});
|
||||
REQUIRE(w.has<ChosenOne>(e1));
|
||||
w.set(e1, ChoosenOne{});
|
||||
REQUIRE(w.has<ChoosenOne>(e1));
|
||||
|
||||
auto e2 = w.make_entity();
|
||||
w.set(e2, ChosenOne{});
|
||||
REQUIRE(w.has<ChosenOne>(e2));
|
||||
w.set(e2, ChoosenOne{});
|
||||
REQUIRE(w.has<ChoosenOne>(e2));
|
||||
}
|
||||
|
||||
struct Comp
|
||||
|
@ -111,21 +111,21 @@ TEST_CASE(
|
|||
world w;
|
||||
|
||||
auto e = w.make_entity();
|
||||
w.set(e, ChosenOne{});
|
||||
REQUIRE_NOTHROW(w.remove<ChosenOne>(e));
|
||||
w.set(e, ChoosenOne{});
|
||||
REQUIRE_NOTHROW(w.remove<ChoosenOne>(e));
|
||||
|
||||
REQUIRE_FALSE(w.has<ChosenOne>(e));
|
||||
REQUIRE_FALSE(w.has<ChoosenOne>(e));
|
||||
|
||||
w.set(e, ChosenOne{});
|
||||
REQUIRE_NOTHROW(w.remove<ChosenOne>(e));
|
||||
REQUIRE_FALSE(w.has<ChosenOne>(e));
|
||||
w.set(e, ChoosenOne{});
|
||||
REQUIRE_NOTHROW(w.remove<ChoosenOne>(e));
|
||||
REQUIRE_FALSE(w.has<ChoosenOne>(e));
|
||||
}
|
||||
|
||||
TEST_CASE("Addresses of removed components should be reused", "[test]")
|
||||
{
|
||||
world w;
|
||||
std::vector<entity_id> entities;
|
||||
std::vector<ChosenOne*> addr;
|
||||
std::vector<ChoosenOne*> addr;
|
||||
|
||||
const int N = 4;
|
||||
|
||||
|
@ -134,14 +134,14 @@ TEST_CASE("Addresses of removed components should be reused", "[test]")
|
|||
for(int j = 0; j < N; ++j)
|
||||
{
|
||||
entities.emplace_back(w.make_entity());
|
||||
w.set<ChosenOne>(entities.back());
|
||||
w.set<ChoosenOne>(entities.back());
|
||||
}
|
||||
|
||||
if(addr.empty())
|
||||
{
|
||||
for(int j = 0; j < N; ++j)
|
||||
{
|
||||
addr.emplace_back(&w.get<ChosenOne>(entities[j]));
|
||||
addr.emplace_back(&w.get<ChoosenOne>(entities[j]));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -153,13 +153,13 @@ TEST_CASE("Addresses of removed components should be reused", "[test]")
|
|||
|
||||
for(int j = 0; j < N; ++j)
|
||||
{
|
||||
REQUIRE(&w.get<ChosenOne>(entities[j]) == addr[j]);
|
||||
REQUIRE(&w.get<ChoosenOne>(entities[j]) == addr[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for(auto e: entities)
|
||||
{
|
||||
w.remove<ChosenOne>(e);
|
||||
w.remove<ChoosenOne>(e);
|
||||
}
|
||||
entities.clear();
|
||||
}
|
||||
|
@ -172,14 +172,14 @@ TEST_CASE("Attach multiple components to an entity and verify all are "
|
|||
world w;
|
||||
|
||||
auto e = w.make_entity();
|
||||
w.set(e, ChosenOne{}, Comp{});
|
||||
w.set(e, ChoosenOne{}, Comp{});
|
||||
|
||||
REQUIRE(w.has<ChosenOne, Comp>(e));
|
||||
REQUIRE(w.has<ChoosenOne, Comp>(e));
|
||||
|
||||
w.remove<ChosenOne, Comp>(e);
|
||||
w.remove<ChoosenOne, Comp>(e);
|
||||
|
||||
REQUIRE_FALSE(w.has<ChosenOne, Comp>(e));
|
||||
REQUIRE_FALSE(w.has<ChosenOne>(e));
|
||||
REQUIRE_FALSE(w.has<ChoosenOne, Comp>(e));
|
||||
REQUIRE_FALSE(w.has<ChoosenOne>(e));
|
||||
REQUIRE_FALSE(w.has<Comp>(e));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
|
|
Loading…
Reference in a new issue