Add tests for find_center()

This commit is contained in:
hasufell 2014-05-10 22:49:36 +02:00
parent 1b97f290cf
commit 1fa87f9fbf
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
3 changed files with 43 additions and 1 deletions

View File

@ -95,7 +95,11 @@ int main(void)
(NULL == CU_add_test(pSuite, "test3 parsing .obj", (NULL == CU_add_test(pSuite, "test3 parsing .obj",
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, "test1 finding center ob obj",
test_find_center1)) ||
(NULL == CU_add_test(pSuite, "test2 finding center ob obj",
test_find_center2))
) { ) {
CU_cleanup_registry(); CU_cleanup_registry();

View File

@ -35,3 +35,6 @@ 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_find_center1(void);
void test_find_center2(void);

View File

@ -427,3 +427,38 @@ void test_parse_obj4(void)
CU_ASSERT_PTR_NULL(obj); CU_ASSERT_PTR_NULL(obj);
} }
void test_find_center1(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);
HE_vert *newvert = find_center(obj);
CU_ASSERT_PTR_NOT_NULL(obj);
CU_ASSERT_EQUAL(newvert->x, 10.0);
CU_ASSERT_EQUAL(newvert->y, 10.5);
CU_ASSERT_EQUAL(newvert->z, 10.0);
}
void test_find_center2(void)
{
HE_vert *newvert = find_center(NULL);
CU_ASSERT_PTR_NULL(newvert);
}