more tests
This commit is contained in:
1
TODO
1
TODO
@@ -29,5 +29,4 @@ TODO
|
||||
- inline variables are fine here, only the head represents a problem
|
||||
- we should always resolve by looking into the list of types when working across boundaries, no direct resolve
|
||||
* nested groups: AB/ABC/ABCD/... (hints: sort, check functions)
|
||||
* use make_tuple and reference_wrapper instead of explicing tuple<T &>
|
||||
* improve multi-stomp so as to reuse the known pool and the known element
|
||||
|
||||
@@ -279,25 +279,28 @@ TEST(NonOwningGroup, IndexRebuiltOnDestroy) {
|
||||
|
||||
TEST(NonOwningGroup, ConstNonConstAndAllInBetween) {
|
||||
entt::registry registry;
|
||||
auto group = registry.group(entt::get<int, const char>);
|
||||
auto group = registry.group(entt::get<int, const char, entt::tag<"empty"_hs>>);
|
||||
|
||||
ASSERT_EQ(group.size(), decltype(group.size()){0});
|
||||
|
||||
const auto entity = registry.create();
|
||||
registry.assign<int>(entity, 0);
|
||||
registry.assign<char>(entity, 'c');
|
||||
registry.assign<entt::tag<"empty"_hs>>(entity);
|
||||
|
||||
ASSERT_EQ(group.size(), decltype(group.size()){1});
|
||||
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<int>(entt::entity{0})), int &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<const char>(entt::entity{0})), const char &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char>(entt::entity{0})), std::tuple<int &, const char &>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<entt::tag<"empty"_hs>>(entt::entity{0})), entt::tag<"empty"_hs>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, entt::tag<"empty"_hs>>(entt::entity{0})), std::tuple<int &, const char &, entt::tag<"empty"_hs>>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.raw<const char>()), const char *>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.raw<int>()), int *>));
|
||||
|
||||
group.each([](auto, auto &&i, auto &&c) {
|
||||
group.each([](auto &&i, auto &&c, auto &&e) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(i), int &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(c), const char &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(e), entt::tag<"empty"_hs> &&>));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -789,7 +792,7 @@ TEST(OwningGroup, IndexRebuiltOnDestroy) {
|
||||
|
||||
TEST(OwningGroup, ConstNonConstAndAllInBetween) {
|
||||
entt::registry registry;
|
||||
auto group = registry.group<int, const char>(entt::get<double, const float>);
|
||||
auto group = registry.group<int, const char>(entt::get<double, const float, entt::tag<"empty"_hs>>);
|
||||
|
||||
ASSERT_EQ(group.size(), decltype(group.size()){0});
|
||||
|
||||
@@ -798,6 +801,7 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) {
|
||||
registry.assign<char>(entity, 'c');
|
||||
registry.assign<double>(entity, 0.);
|
||||
registry.assign<float>(entity, 0.f);
|
||||
registry.assign<entt::tag<"empty"_hs>>(entity);
|
||||
|
||||
ASSERT_EQ(group.size(), decltype(group.size()){1});
|
||||
|
||||
@@ -805,17 +809,19 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<const char>(entt::entity{0})), const char &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<double>(entt::entity{0})), double &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<const float>(entt::entity{0})), const float &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, double, const float>(entt::entity{0})), std::tuple<int &, const char &, double &, const float &>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<entt::tag<"empty"_hs>>(entt::entity{0})), entt::tag<"empty"_hs>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, double, const float, entt::tag<"empty"_hs>>(entt::entity{0})), std::tuple<int &, const char &, double &, const float &, entt::tag<"empty"_hs>>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.raw<const float>()), const float *>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.raw<double>()), double *>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.raw<const char>()), const char *>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(group.raw<int>()), int *>));
|
||||
|
||||
group.each([](auto, auto &&i, auto &&c, auto &&d, auto &&f) {
|
||||
group.each([](auto &&i, auto &&c, auto &&d, auto &&f, auto &&e) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(i), int &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(c), const char &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(d), double &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(f), const float &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(e), entt::tag<"empty"_hs> &&>));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -141,11 +141,11 @@ TEST(SingleComponentView, ConstNonConstAndAllInBetween) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(cview.get(entt::entity{0})), const int &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(cview.raw()), const int *>));
|
||||
|
||||
view.each([](auto, auto &&i) {
|
||||
view.each([](auto &&i) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(i), int &>));
|
||||
});
|
||||
|
||||
cview.each([](auto, auto &&i) {
|
||||
cview.each([](auto &&i) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(i), const int &>));
|
||||
});
|
||||
}
|
||||
@@ -406,25 +406,28 @@ TEST(MultipleComponentView, EachWithHoles) {
|
||||
|
||||
TEST(MultipleComponentView, ConstNonConstAndAllInBetween) {
|
||||
entt::registry registry;
|
||||
auto view = registry.view<int, const char>();
|
||||
auto view = registry.view<int, const char, entt::tag<"empty"_hs>>();
|
||||
|
||||
ASSERT_EQ(view.size(), decltype(view.size()){0});
|
||||
|
||||
const auto entity = registry.create();
|
||||
registry.assign<int>(entity, 0);
|
||||
registry.assign<char>(entity, 'c');
|
||||
registry.assign<entt::tag<"empty"_hs>>(entity);
|
||||
|
||||
ASSERT_EQ(view.size(), decltype(view.size()){1});
|
||||
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.get<int>(entt::entity{0})), int &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.get<const char>(entt::entity{0})), const char &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.get<int, const char>(entt::entity{0})), std::tuple<int &, const char &>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.get<entt::tag<"empty"_hs>>(entt::entity{0})), entt::tag<"empty"_hs>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.get<int, const char, entt::tag<"empty"_hs>>(entt::entity{0})), std::tuple<int &, const char &, entt::tag<"empty"_hs>>>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.raw<const char>()), const char *>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(view.raw<int>()), int *>));
|
||||
|
||||
view.each([](auto, auto &&i, auto &&c) {
|
||||
view.each([](auto &&i, auto &&c, auto &&e) {
|
||||
ASSERT_TRUE((std::is_same_v<decltype(i), int &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(c), const char &>));
|
||||
ASSERT_TRUE((std::is_same_v<decltype(e), entt::tag<"empty"_hs> &&>));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user