zecsy/tests/zecsy.c

59 lines
1 KiB
C
Raw Normal View History

2025-03-20 20:09:25 +03:00
#include <stdio.h>
2025-03-20 18:12:46 +03:00
#include <stdlib.h>
2025-03-19 21:08:58 +03:00
#define CLOVE_IMPLEMENTATION
#include <clove-unit.h>
2025-03-20 18:12:46 +03:00
#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)
2025-03-19 21:08:58 +03:00
{
2025-03-20 18:12:46 +03:00
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);
2025-03-20 20:09:25 +03:00
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));
2025-03-20 18:12:46 +03:00
destroy_world(&w);
}
CLOVE_TEST(dead_entities)
{
world* w = NULL;
make_world(&w);
entity_id e = make_entity(w);
destroy_entity(w, e);
2025-03-20 20:09:25 +03:00
CLOVE_IS_FALSE(is_alive(w, e));
2025-03-20 18:12:46 +03:00
destroy_world(&w);
2025-03-19 21:08:58 +03:00
}
CLOVE_RUNNER()