First try of consistent half-edge struct test

This commit is contained in:
hasufell 2014-05-14 01:40:39 +02:00
parent 1bd4bfa1b7
commit 6ceeff5a7b
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
3 changed files with 43 additions and 0 deletions

View File

@ -102,6 +102,8 @@ int main(void)
test_parse_obj3)) || test_parse_obj3)) ||
(NULL == CU_add_test(pSuite, "test4 parsing .obj", (NULL == CU_add_test(pSuite, "test4 parsing .obj",
test_parse_obj4)) || test_parse_obj4)) ||
(NULL == CU_add_test(pSuite, "test5 parsing .obj",
test_parse_obj5)) ||
(NULL == CU_add_test(pSuite, "test1 finding center ob obj", (NULL == CU_add_test(pSuite, "test1 finding center ob obj",
test_find_center1)) || test_find_center1)) ||
(NULL == CU_add_test(pSuite, "test2 finding center ob obj", (NULL == CU_add_test(pSuite, "test2 finding center ob obj",

View File

@ -42,6 +42,7 @@ void test_parse_obj1(void);
void test_parse_obj2(void); void test_parse_obj2(void);
void test_parse_obj3(void); void test_parse_obj3(void);
void test_parse_obj4(void); void test_parse_obj4(void);
void test_parse_obj5(void);
void test_find_center1(void); void test_find_center1(void);
void test_find_center2(void); void test_find_center2(void);

View File

@ -436,6 +436,46 @@ void test_parse_obj4(void)
CU_ASSERT_PTR_NULL(obj); CU_ASSERT_PTR_NULL(obj);
} }
/**
* Test the whole object for consistency by walking
* through all faces and checking the respective half-edges
* ans pairs.
*/
void test_parse_obj5(void)
{
char const * const string = ""
"v 9.0 10.0 11.0\n"
"v 11.0 10.0 11.0\n"
"v 9.0 11.0 11.0\n"
"v 11.0 11.0 11.0\n"
"v 9.0 11.0 9.0\n"
"v 11.0 11.0 9.0\n"
"v 9.0 10.0 9.0\n"
"v 11.0 10.0 9.0\n"
"f 1 2 4 3\n"
"f 3 4 6 5\n"
"f 5 6 8 7\n"
"f 7 8 2 1\n"
"f 2 8 6 4\n"
"f 7 1 3 5\n";
HE_obj *obj = parse_obj(string);
CU_ASSERT_PTR_NOT_NULL(obj);
for (uint32_t i = 0; i < obj->fc; i++) {
HE_edge *start_edge = &(obj->faces[i].edge[0]),
*next_edge = start_edge->next;
while(next_edge != start_edge) {
CU_ASSERT_PTR_NOT_NULL(next_edge);
CU_ASSERT_PTR_NOT_NULL(next_edge->pair->pair);
CU_ASSERT_EQUAL(next_edge->face, &(obj->faces[i]));
CU_ASSERT_EQUAL(next_edge->pair->pair, next_edge);
next_edge = next_edge->next;
}
}
}
/** /**
* Test finding the center of an object. * Test finding the center of an object.
*/ */