1#include <gtest/gtest.h>
11TEST(SparseArrayTest, EraseNonExistingIsNoop) {
14 EXPECT_NO_THROW(arr.
erase(e1));
15 EXPECT_TRUE(arr.
empty());
16 EXPECT_EQ(arr.
size(), 0u);
19TEST(SparseArrayTest, OverwriteKeepsSizeOne) {
24 EXPECT_EQ(arr.
size(), 1u);
25 EXPECT_EQ(arr[e].value, 20);
28TEST(SparseArrayTest, EraseSwapBackMaintainsMapping) {
40 EXPECT_EQ(arr.
size(), 2u);
41 EXPECT_FALSE(arr.
has(e2));
43 ASSERT_TRUE(arr.
has(e1));
44 ASSERT_TRUE(arr.
has(e3));
46 EXPECT_EQ(arr[e1].value, 1);
47 EXPECT_EQ(arr[e3].value, 3);
50TEST(SparseArrayTest, EntitiesAndDataSizesStayConsistent) {
Entity identifier for ECS architecture.
Sparse array container for efficient component storage in ECS.
Represents an entity in the ECS (Entity-Component-System) architecture.
Sparse array container for component storage.
bool has(Entity entity) const noexcept override final
Check if an entity has this component.
std::span< Entity > entities() noexcept
Get the entity array corresponding to components.
T & emplace(Entity entity, Args &&...args)
Construct a component in-place for an entity.
void erase(Entity entity) noexcept override final
Remove a component from an entity.
std::size_t size(void) const noexcept
Get the number of components stored.
bool empty(void) const noexcept
Check if the array is empty.
File : RenderSystem.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
TEST(SparseArrayTest, EraseNonExistingIsNoop)