|
@@ -8,66 +8,66 @@ COMPONENTS(int, Int)
|
|
|
COMPONENTS_SOURCE(int, Int)
|
|
|
|
|
|
static void testAddForEach() {
|
|
|
- Components c;
|
|
|
- initComponents(&c);
|
|
|
+ ComponentsInt c;
|
|
|
+ initComponentsInt(&c);
|
|
|
|
|
|
- int* i1 = getOrAddComponent(&c, 1);
|
|
|
+ int* i1 = getOrAddComponentInt(&c, 1);
|
|
|
if(TEST_NOT_NULL(i1)) {
|
|
|
*i1 = 10;
|
|
|
}
|
|
|
- int* i2 = getOrAddComponent(&c, 1);
|
|
|
+ int* i2 = getOrAddComponentInt(&c, 1);
|
|
|
if(TEST_NOT_NULL(i2)) {
|
|
|
*i2 = 15;
|
|
|
}
|
|
|
- int* i3 = getOrAddComponent(&c, 5);
|
|
|
+ int* i3 = getOrAddComponentInt(&c, 5);
|
|
|
if(TEST_NOT_NULL(i3)) {
|
|
|
*i3 = 20;
|
|
|
}
|
|
|
- int* i4 = getOrAddComponent(&c, 10);
|
|
|
+ int* i4 = getOrAddComponentInt(&c, 10);
|
|
|
if(TEST_NOT_NULL(i4)) {
|
|
|
*i4 = 30;
|
|
|
}
|
|
|
TEST_TRUE(i1 == i2);
|
|
|
|
|
|
- ComponentIterator iter;
|
|
|
- initComponentIterator(&iter, &c);
|
|
|
- if(TEST_TRUE(hasNextComponentNode(&iter))) {
|
|
|
- ComponentNode* n = nextComponentNode(&iter);
|
|
|
+ ComponentIteratorInt iter;
|
|
|
+ initComponentIteratorInt(&iter, &c);
|
|
|
+ if(TEST_TRUE(hasNextComponentNodeInt(&iter))) {
|
|
|
+ ComponentNodeInt* n = nextComponentNodeInt(&iter);
|
|
|
TEST_SIZE(1, n->entity);
|
|
|
TEST_INT(15, *n->component);
|
|
|
}
|
|
|
- if(TEST_TRUE(hasNextComponentNode(&iter))) {
|
|
|
- ComponentNode* n = nextComponentNode(&iter);
|
|
|
+ if(TEST_TRUE(hasNextComponentNodeInt(&iter))) {
|
|
|
+ ComponentNodeInt* n = nextComponentNodeInt(&iter);
|
|
|
TEST_SIZE(5, n->entity);
|
|
|
TEST_INT(20, *n->component);
|
|
|
}
|
|
|
- if(TEST_TRUE(hasNextComponentNode(&iter))) {
|
|
|
- ComponentNode* n = nextComponentNode(&iter);
|
|
|
+ if(TEST_TRUE(hasNextComponentNodeInt(&iter))) {
|
|
|
+ ComponentNodeInt* n = nextComponentNodeInt(&iter);
|
|
|
TEST_SIZE(10, n->entity);
|
|
|
TEST_INT(30, *n->component);
|
|
|
}
|
|
|
- TEST_FALSE(hasNextComponentNode(&iter));
|
|
|
- destroyComponents(&c);
|
|
|
+ TEST_FALSE(hasNextComponentNodeInt(&iter));
|
|
|
+ destroyComponentsInt(&c);
|
|
|
}
|
|
|
|
|
|
static void testAddComponentForEach() {
|
|
|
- Components c;
|
|
|
- initComponents(&c);
|
|
|
- int* i1 = getOrAddComponent(&c, 1);
|
|
|
+ ComponentsInt c;
|
|
|
+ initComponentsInt(&c);
|
|
|
+ int* i1 = getOrAddComponentInt(&c, 1);
|
|
|
if(TEST_NOT_NULL(i1)) {
|
|
|
*i1 = 10;
|
|
|
}
|
|
|
- int* i2 = getOrAddComponent(&c, 5);
|
|
|
+ int* i2 = getOrAddComponentInt(&c, 5);
|
|
|
if(TEST_NOT_NULL(i2)) {
|
|
|
*i2 = 20;
|
|
|
}
|
|
|
- int* i3 = getOrAddComponent(&c, 10);
|
|
|
+ int* i3 = getOrAddComponentInt(&c, 10);
|
|
|
if(TEST_NOT_NULL(i3)) {
|
|
|
*i3 = 30;
|
|
|
}
|
|
|
|
|
|
- int* iter = getComponentsStart(&c);
|
|
|
- int* end = getComponentsEnd(&c);
|
|
|
+ int* iter = getComponentsStartInt(&c);
|
|
|
+ int* end = getComponentsEndInt(&c);
|
|
|
if(TEST_TRUE(iter != end)) {
|
|
|
TEST_INT(10, *(iter++));
|
|
|
}
|
|
@@ -78,45 +78,45 @@ static void testAddComponentForEach() {
|
|
|
TEST_INT(30, *(iter++));
|
|
|
}
|
|
|
TEST_TRUE(iter == end);
|
|
|
- destroyComponents(&c);
|
|
|
+ destroyComponentsInt(&c);
|
|
|
}
|
|
|
|
|
|
static void testRemove() {
|
|
|
- Components c;
|
|
|
- initComponents(&c);
|
|
|
- *getOrAddComponent(&c, 1) = 10;
|
|
|
- *getOrAddComponent(&c, 5) = 20;
|
|
|
- *getOrAddComponent(&c, 10) = 30;
|
|
|
+ ComponentsInt c;
|
|
|
+ initComponentsInt(&c);
|
|
|
+ *getOrAddComponentInt(&c, 1) = 10;
|
|
|
+ *getOrAddComponentInt(&c, 5) = 20;
|
|
|
+ *getOrAddComponentInt(&c, 10) = 30;
|
|
|
|
|
|
- TEST_FALSE(removeComponent(&c, 20));
|
|
|
- TEST_TRUE(removeComponent(&c, 5));
|
|
|
- TEST_FALSE(removeComponent(&c, 30));
|
|
|
+ TEST_FALSE(removeComponentInt(&c, 20));
|
|
|
+ TEST_TRUE(removeComponentInt(&c, 5));
|
|
|
+ TEST_FALSE(removeComponentInt(&c, 30));
|
|
|
|
|
|
- *getOrAddComponent(&c, 20) = 40;
|
|
|
- TEST_TRUE(removeComponent(&c, 20));
|
|
|
+ *getOrAddComponentInt(&c, 20) = 40;
|
|
|
+ TEST_TRUE(removeComponentInt(&c, 20));
|
|
|
|
|
|
- int* i1 = searchComponent(&c, 1);
|
|
|
- int* i3 = searchComponent(&c, 10);
|
|
|
- TEST_NULL(searchComponent(&c, 5));
|
|
|
+ int* i1 = searchComponentInt(&c, 1);
|
|
|
+ int* i3 = searchComponentInt(&c, 10);
|
|
|
+ TEST_NULL(searchComponentInt(&c, 5));
|
|
|
if(TEST_NOT_NULL(i1) && TEST_NOT_NULL(i3)) {
|
|
|
TEST_INT(10, *i1);
|
|
|
TEST_INT(30, *i3);
|
|
|
}
|
|
|
|
|
|
- TEST_TRUE(removeComponent(&c, 10));
|
|
|
- i1 = searchComponent(&c, 1);
|
|
|
- TEST_NULL(searchComponent(&c, 5));
|
|
|
- TEST_NULL(searchComponent(&c, 10));
|
|
|
+ TEST_TRUE(removeComponentInt(&c, 10));
|
|
|
+ i1 = searchComponentInt(&c, 1);
|
|
|
+ TEST_NULL(searchComponentInt(&c, 5));
|
|
|
+ TEST_NULL(searchComponentInt(&c, 10));
|
|
|
if(TEST_NOT_NULL(i1)) {
|
|
|
TEST_INT(10, *i1);
|
|
|
}
|
|
|
|
|
|
- TEST_TRUE(removeComponent(&c, 1));
|
|
|
- TEST_NULL(searchComponent(&c, 1));
|
|
|
- TEST_NULL(searchComponent(&c, 5));
|
|
|
- TEST_NULL(searchComponent(&c, 10));
|
|
|
+ TEST_TRUE(removeComponentInt(&c, 1));
|
|
|
+ TEST_NULL(searchComponentInt(&c, 1));
|
|
|
+ TEST_NULL(searchComponentInt(&c, 5));
|
|
|
+ TEST_NULL(searchComponentInt(&c, 10));
|
|
|
|
|
|
- destroyComponents(&c);
|
|
|
+ destroyComponentsInt(&c);
|
|
|
}
|
|
|
|
|
|
void testComponents() {
|