Skip to content

Commit

Permalink
let's try something that perhaps even VS can understand
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Aug 22, 2019
1 parent 15ff1a5 commit 1437063
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
22 changes: 10 additions & 12 deletions test/entt/entity/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,29 +279,28 @@ TEST(NonOwningGroup, IndexRebuiltOnDestroy) {

TEST(NonOwningGroup, ConstNonConstAndAllInBetween) {
entt::registry registry;
auto group = registry.group(entt::get<int, const char, entt::tag<"empty"_hs>>);
auto group = registry.group(entt::get<int, const char, std::true_type>);

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);
registry.assign<std::true_type>(entity);

ASSERT_EQ(group.size(), decltype(group.size()){1});

ASSERT_TRUE((std::is_same_v<decltype(group.get<int>({})), int &>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<const char>({})), const char &>));
// commented out because of an ICE with VS2019 :facepalm:
// ASSERT_TRUE((std::is_same_v<decltype(group.get<entt::tag<"empty"_hs>>({})), entt::tag<"empty"_hs>>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, entt::tag<"empty"_hs>>({})), std::tuple<int &, const char &, entt::tag<"empty"_hs>>>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<std::true_type>({})), std::true_type>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, std::true_type>({})), std::tuple<int &, const char &, std::true_type>>));
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 &&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> &&>));
ASSERT_TRUE((std::is_same_v<decltype(e), std::true_type &&>));
});
}

Expand Down Expand Up @@ -793,7 +792,7 @@ TEST(OwningGroup, IndexRebuiltOnDestroy) {

TEST(OwningGroup, ConstNonConstAndAllInBetween) {
entt::registry registry;
auto group = registry.group<int, const char>(entt::get<double, const float, entt::tag<"empty"_hs>>);
auto group = registry.group<int, const char>(entt::get<double, const float, std::true_type>);

ASSERT_EQ(group.size(), decltype(group.size()){0});

Expand All @@ -802,17 +801,16 @@ 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);
registry.assign<std::true_type>(entity);

ASSERT_EQ(group.size(), decltype(group.size()){1});

ASSERT_TRUE((std::is_same_v<decltype(group.get<int>({})), int &>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<const char>({})), const char &>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<double>({})), double &>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<const float>({})), const float &>));
// commented out because of an ICE with VS2019 :facepalm:
// ASSERT_TRUE((std::is_same_v<decltype(group.get<entt::tag<"empty"_hs>>({})), entt::tag<"empty"_hs>>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, double, const float, entt::tag<"empty"_hs>>({})), std::tuple<int &, const char &, double &, const float &, entt::tag<"empty"_hs>>>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<std::true_type>({})), std::true_type>));
ASSERT_TRUE((std::is_same_v<decltype(group.get<int, const char, double, const float, std::true_type>({})), std::tuple<int &, const char &, double &, const float &, std::true_type>>));
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 *>));
Expand All @@ -823,7 +821,7 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) {
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> &&>));
ASSERT_TRUE((std::is_same_v<decltype(e), std::true_type &&>));
});
}

Expand Down
11 changes: 5 additions & 6 deletions test/entt/entity/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,29 +406,28 @@ TEST(MultipleComponentView, EachWithHoles) {

TEST(MultipleComponentView, ConstNonConstAndAllInBetween) {
entt::registry registry;
auto view = registry.view<int, const char, entt::tag<"empty"_hs>>();
auto view = registry.view<int, const char, std::true_type>();

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);
registry.assign<std::true_type>(entity);

ASSERT_EQ(view.size(), decltype(view.size()){1});

ASSERT_TRUE((std::is_same_v<decltype(view.get<int>({})), int &>));
ASSERT_TRUE((std::is_same_v<decltype(view.get<const char>({})), const char &>));
// commented out because of an ICE with VS2019 :facepalm:
// ASSERT_TRUE((std::is_same_v<decltype(view.get<entt::tag<"empty"_hs>>({})), entt::tag<"empty"_hs>>));
ASSERT_TRUE((std::is_same_v<decltype(view.get<int, const char, entt::tag<"empty"_hs>>({})), std::tuple<int &, const char &, entt::tag<"empty"_hs>>>));
ASSERT_TRUE((std::is_same_v<decltype(view.get<std::true_type>({})), std::true_type>));
ASSERT_TRUE((std::is_same_v<decltype(view.get<int, const char, std::true_type>({})), std::tuple<int &, const char &, std::true_type>>));
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 &&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> &&>));
ASSERT_TRUE((std::is_same_v<decltype(e), std::true_type &&>));
});
}

Expand Down

0 comments on commit 1437063

Please sign in to comment.