|
@@ -2,115 +2,115 @@
|
|
|
#include "core/Components.h"
|
|
|
|
|
|
static void testAddForEach() {
|
|
|
- CoreComponents c;
|
|
|
- coreInitComponents(&c, sizeof(int));
|
|
|
+ Components c;
|
|
|
+ initComponents(&c, sizeof(int));
|
|
|
|
|
|
- int* i1 = coreComponentsGetOrAdd(&c, 1);
|
|
|
- if(CORE_TEST_NOT_NULL(i1)) {
|
|
|
+ int* i1 = getOrAddComponent(&c, 1);
|
|
|
+ if(TEST_NOT_NULL(i1)) {
|
|
|
*i1 = 10;
|
|
|
}
|
|
|
- int* i2 = coreComponentsGetOrAdd(&c, 1);
|
|
|
- if(CORE_TEST_NOT_NULL(i2)) {
|
|
|
+ int* i2 = getOrAddComponent(&c, 1);
|
|
|
+ if(TEST_NOT_NULL(i2)) {
|
|
|
*i2 = 15;
|
|
|
}
|
|
|
- int* i3 = coreComponentsGetOrAdd(&c, 5);
|
|
|
- if(CORE_TEST_NOT_NULL(i3)) {
|
|
|
+ int* i3 = getOrAddComponent(&c, 5);
|
|
|
+ if(TEST_NOT_NULL(i3)) {
|
|
|
*i3 = 20;
|
|
|
}
|
|
|
- int* i4 = coreComponentsGetOrAdd(&c, 10);
|
|
|
- if(CORE_TEST_NOT_NULL(i4)) {
|
|
|
+ int* i4 = getOrAddComponent(&c, 10);
|
|
|
+ if(TEST_NOT_NULL(i4)) {
|
|
|
*i4 = 30;
|
|
|
}
|
|
|
- CORE_TEST_TRUE(i1 == i2);
|
|
|
+ TEST_TRUE(i1 == i2);
|
|
|
|
|
|
- CoreComponentIterator iter;
|
|
|
- coreInitComponentsIterator(&iter, &c);
|
|
|
- if(CORE_TEST_TRUE(coreComponentsHasNext(&iter))) {
|
|
|
- CoreComponentNode* n = coreComponentsNext(&iter);
|
|
|
- CORE_TEST_SIZE(1, n->entity);
|
|
|
- CORE_TEST_INT(15, *(int*)n->component);
|
|
|
+ ComponentIterator iter;
|
|
|
+ initComponentIterator(&iter, &c);
|
|
|
+ if(TEST_TRUE(hasNextComponentNode(&iter))) {
|
|
|
+ ComponentNode* n = nextComponentNode(&iter);
|
|
|
+ TEST_SIZE(1, n->entity);
|
|
|
+ TEST_INT(15, *(int*)n->component);
|
|
|
}
|
|
|
- if(CORE_TEST_TRUE(coreComponentsHasNext(&iter))) {
|
|
|
- CoreComponentNode* n = coreComponentsNext(&iter);
|
|
|
- CORE_TEST_SIZE(5, n->entity);
|
|
|
- CORE_TEST_INT(20, *(int*)n->component);
|
|
|
+ if(TEST_TRUE(hasNextComponentNode(&iter))) {
|
|
|
+ ComponentNode* n = nextComponentNode(&iter);
|
|
|
+ TEST_SIZE(5, n->entity);
|
|
|
+ TEST_INT(20, *(int*)n->component);
|
|
|
}
|
|
|
- if(CORE_TEST_TRUE(coreComponentsHasNext(&iter))) {
|
|
|
- CoreComponentNode* n = coreComponentsNext(&iter);
|
|
|
- CORE_TEST_SIZE(10, n->entity);
|
|
|
- CORE_TEST_INT(30, *(int*)n->component);
|
|
|
+ if(TEST_TRUE(hasNextComponentNode(&iter))) {
|
|
|
+ ComponentNode* n = nextComponentNode(&iter);
|
|
|
+ TEST_SIZE(10, n->entity);
|
|
|
+ TEST_INT(30, *(int*)n->component);
|
|
|
}
|
|
|
- CORE_TEST_FALSE(coreComponentsHasNext(&iter));
|
|
|
- coreDestroyComponents(&c);
|
|
|
+ TEST_FALSE(hasNextComponentNode(&iter));
|
|
|
+ destroyComponents(&c);
|
|
|
}
|
|
|
|
|
|
static void testAddComponentForEach() {
|
|
|
- CoreComponents c;
|
|
|
- coreInitComponents(&c, sizeof(int));
|
|
|
- int* i1 = coreComponentsGetOrAdd(&c, 1);
|
|
|
- if(CORE_TEST_NOT_NULL(i1)) {
|
|
|
+ Components c;
|
|
|
+ initComponents(&c, sizeof(int));
|
|
|
+ int* i1 = getOrAddComponent(&c, 1);
|
|
|
+ if(TEST_NOT_NULL(i1)) {
|
|
|
*i1 = 10;
|
|
|
}
|
|
|
- int* i2 = coreComponentsGetOrAdd(&c, 5);
|
|
|
- if(CORE_TEST_NOT_NULL(i2)) {
|
|
|
+ int* i2 = getOrAddComponent(&c, 5);
|
|
|
+ if(TEST_NOT_NULL(i2)) {
|
|
|
*i2 = 20;
|
|
|
}
|
|
|
- int* i3 = coreComponentsGetOrAdd(&c, 10);
|
|
|
- if(CORE_TEST_NOT_NULL(i3)) {
|
|
|
+ int* i3 = getOrAddComponent(&c, 10);
|
|
|
+ if(TEST_NOT_NULL(i3)) {
|
|
|
*i3 = 30;
|
|
|
}
|
|
|
|
|
|
- int* iter = coreComponentsBegin(&c);
|
|
|
- int* end = coreComponentsEnd(&c);
|
|
|
- if(CORE_TEST_TRUE(iter != end)) {
|
|
|
- CORE_TEST_INT(10, *(iter++));
|
|
|
+ int* iter = getComponentsStart(&c);
|
|
|
+ int* end = getComponentsEnd(&c);
|
|
|
+ if(TEST_TRUE(iter != end)) {
|
|
|
+ TEST_INT(10, *(iter++));
|
|
|
}
|
|
|
- if(CORE_TEST_TRUE(iter != end)) {
|
|
|
- CORE_TEST_INT(20, *(iter++));
|
|
|
+ if(TEST_TRUE(iter != end)) {
|
|
|
+ TEST_INT(20, *(iter++));
|
|
|
}
|
|
|
- if(CORE_TEST_TRUE(iter != end)) {
|
|
|
- CORE_TEST_INT(30, *(iter++));
|
|
|
+ if(TEST_TRUE(iter != end)) {
|
|
|
+ TEST_INT(30, *(iter++));
|
|
|
}
|
|
|
- CORE_TEST_TRUE(iter == end);
|
|
|
- coreDestroyComponents(&c);
|
|
|
+ TEST_TRUE(iter == end);
|
|
|
+ destroyComponents(&c);
|
|
|
}
|
|
|
|
|
|
static void testRemove() {
|
|
|
- CoreComponents c;
|
|
|
- coreInitComponents(&c, sizeof(int));
|
|
|
- *(int*)coreComponentsGetOrAdd(&c, 1) = 10;
|
|
|
- *(int*)coreComponentsGetOrAdd(&c, 5) = 20;
|
|
|
- *(int*)coreComponentsGetOrAdd(&c, 10) = 30;
|
|
|
+ Components c;
|
|
|
+ initComponents(&c, sizeof(int));
|
|
|
+ *(int*)getOrAddComponent(&c, 1) = 10;
|
|
|
+ *(int*)getOrAddComponent(&c, 5) = 20;
|
|
|
+ *(int*)getOrAddComponent(&c, 10) = 30;
|
|
|
|
|
|
- CORE_TEST_FALSE(coreComponentsRemove(&c, 20));
|
|
|
- CORE_TEST_TRUE(coreComponentsRemove(&c, 5));
|
|
|
- CORE_TEST_FALSE(coreComponentsRemove(&c, 30));
|
|
|
+ TEST_FALSE(removeComponent(&c, 20));
|
|
|
+ TEST_TRUE(removeComponent(&c, 5));
|
|
|
+ TEST_FALSE(removeComponent(&c, 30));
|
|
|
|
|
|
- *(int*)coreComponentsGetOrAdd(&c, 20) = 40;
|
|
|
- CORE_TEST_TRUE(coreComponentsRemove(&c, 20));
|
|
|
+ *(int*)getOrAddComponent(&c, 20) = 40;
|
|
|
+ TEST_TRUE(removeComponent(&c, 20));
|
|
|
|
|
|
- int* i1 = coreComponentsSearch(&c, 1);
|
|
|
- int* i3 = coreComponentsSearch(&c, 10);
|
|
|
- CORE_TEST_NULL(coreComponentsSearch(&c, 5));
|
|
|
- if(CORE_TEST_NOT_NULL(i1) && CORE_TEST_NOT_NULL(i3)) {
|
|
|
- CORE_TEST_INT(10, *i1);
|
|
|
- CORE_TEST_INT(30, *i3);
|
|
|
+ int* i1 = searchComponent(&c, 1);
|
|
|
+ int* i3 = searchComponent(&c, 10);
|
|
|
+ TEST_NULL(searchComponent(&c, 5));
|
|
|
+ if(TEST_NOT_NULL(i1) && TEST_NOT_NULL(i3)) {
|
|
|
+ TEST_INT(10, *i1);
|
|
|
+ TEST_INT(30, *i3);
|
|
|
}
|
|
|
|
|
|
- CORE_TEST_TRUE(coreComponentsRemove(&c, 10));
|
|
|
- i1 = coreComponentsSearch(&c, 1);
|
|
|
- CORE_TEST_NULL(coreComponentsSearch(&c, 5));
|
|
|
- CORE_TEST_NULL(coreComponentsSearch(&c, 10));
|
|
|
- if(CORE_TEST_NOT_NULL(i1)) {
|
|
|
- CORE_TEST_INT(10, *i1);
|
|
|
+ TEST_TRUE(removeComponent(&c, 10));
|
|
|
+ i1 = searchComponent(&c, 1);
|
|
|
+ TEST_NULL(searchComponent(&c, 5));
|
|
|
+ TEST_NULL(searchComponent(&c, 10));
|
|
|
+ if(TEST_NOT_NULL(i1)) {
|
|
|
+ TEST_INT(10, *i1);
|
|
|
}
|
|
|
|
|
|
- CORE_TEST_TRUE(coreComponentsRemove(&c, 1));
|
|
|
- CORE_TEST_NULL(coreComponentsSearch(&c, 1));
|
|
|
- CORE_TEST_NULL(coreComponentsSearch(&c, 5));
|
|
|
- CORE_TEST_NULL(coreComponentsSearch(&c, 10));
|
|
|
+ TEST_TRUE(removeComponent(&c, 1));
|
|
|
+ TEST_NULL(searchComponent(&c, 1));
|
|
|
+ TEST_NULL(searchComponent(&c, 5));
|
|
|
+ TEST_NULL(searchComponent(&c, 10));
|
|
|
|
|
|
- coreDestroyComponents(&c);
|
|
|
+ destroyComponents(&c);
|
|
|
}
|
|
|
|
|
|
void testComponents() {
|