コード例 #1
0
#include "Entity.h"

struct Component1
{
    float x, y;
};

DESCRIBE("Component Table")

IT("can create components and retrieve them using entity as key",
{
    ComponentTable<Component1> sut;
    Entity e(1);

    sut.create(e);
    auto &created_component = sut.get(e);
    S_ASSERT(0.0f == created_component.x, "component not created correctly");
});

IT ("can destroy and create components",
{
    // Arrange
    ComponentTable<Component1> sut;
    Entity e(1);
    Entity e2(2);

    // Act
    sut.create(e);
    sut.create(e2);
    sut.get(e2).x = 4.0f;
    sut.destroy(e);