zecsy/tests/zecsy.c
2025-03-20 20:09:25 +03:00

58 lines
1 KiB
C

#include <stdio.h>
#include <stdlib.h>
#define CLOVE_IMPLEMENTATION
#include <clove-unit.h>
#define ZECSY_IMPLEMENTATION
#include "../zecsy.h"
CLOVE_TEST(make_and_delete_empty_world)
{
world* w = NULL;
make_world(&w);
CLOVE_NOT_NULL(w);
CLOVE_SIZET_EQ(RESERVED_ENTITY_ID + 1, w->entity_id_counter);
CLOVE_SIZET_EQ(0, w->alive_entities);
destroy_world(&w);
CLOVE_NULL(w);
}
CLOVE_TEST(pass_null_to_world_free)
{
world* w = NULL;
destroy_world(&w);
CLOVE_NULL(w);
}
CLOVE_TEST(alive_entities)
{
world* w = NULL;
make_world(&w);
entity_id e = make_entity(w);
CLOVE_SIZET_NE(e, RESERVED_ENTITY_ID);
CLOVE_IS_TRUE(is_alive(w, e));
archetype_signature sig = arhetype_of(w, e);
archetype_signature empty_sig = {0};
CLOVE_IS_TRUE(is_same(sig, empty_sig));
destroy_world(&w);
}
CLOVE_TEST(dead_entities)
{
world* w = NULL;
make_world(&w);
entity_id e = make_entity(w);
destroy_entity(w, e);
CLOVE_IS_FALSE(is_alive(w, e));
destroy_world(&w);
}
CLOVE_RUNNER()