diff --git a/src/test/cunit.c b/src/test/cunit.c index 95a89b4..b2913a4 100644 --- a/src/test/cunit.c +++ b/src/test/cunit.c @@ -95,7 +95,11 @@ int main(void) (NULL == CU_add_test(pSuite, "test3 parsing .obj", test_parse_obj3)) || (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(); diff --git a/src/test/cunit.h b/src/test/cunit.h index c55e485..9e7b9c8 100644 --- a/src/test/cunit.h +++ b/src/test/cunit.h @@ -35,3 +35,6 @@ void test_parse_obj1(void); void test_parse_obj2(void); void test_parse_obj3(void); void test_parse_obj4(void); + +void test_find_center1(void); +void test_find_center2(void); diff --git a/src/test/cunit_half_edge.c b/src/test/cunit_half_edge.c index 810d7c0..42eae54 100644 --- a/src/test/cunit_half_edge.c +++ b/src/test/cunit_half_edge.c @@ -427,3 +427,38 @@ void test_parse_obj4(void) 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); +}