Skip to content

Commit

Permalink
test: view ::use and ::refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Jul 11, 2023
1 parent ef11754 commit 1e2f188
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/entt/entity/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,36 @@ TEST(MultiComponentView, SizeHint) {
ASSERT_EQ(view.begin(), view.end());
}

TEST(MultiComponentView, UseAndRefresh) {
entt::registry registry;
entt::entity entity[3]{registry.create(), registry.create(), registry.create()};

registry.emplace<int>(entity[0u]);
registry.emplace<int>(entity[1u]);

registry.emplace<char>(entity[1u]);
registry.emplace<char>(entity[0u]);
registry.emplace<char>(entity[2u]);

auto view = registry.view<int, char>(entt::exclude<double>);

view.use<int>();

ASSERT_EQ(view.handle()->type(), entt::type_id<int>());
ASSERT_EQ(view.front(), entity[1u]);
ASSERT_EQ(view.back(), entity[0u]);

view.use<char>();

ASSERT_EQ(view.handle()->type(), entt::type_id<char>());
ASSERT_EQ(view.front(), entity[0u]);
ASSERT_EQ(view.back(), entity[1u]);

view.refresh();

ASSERT_EQ(view.handle()->type(), entt::type_id<int>());
}

TEST(MultiComponentView, Each) {
entt::registry registry;
entt::entity entity[2]{registry.create(), registry.create()};
Expand Down

0 comments on commit 1e2f188

Please sign in to comment.