GRAPHENE_TEST_UNIT_END GRAPHENE_TEST_UNIT_BEGIN (ray_get_position_at) { graphene_ray_t r; graphene_point3d_t tmp; graphene_ray_init (&r, &one3, graphene_vec3_z_axis ()); if (g_test_verbose ()) g_test_message ("On the ray's origin..."); graphene_ray_get_position_at (&r, 0.f, &tmp); g_assert_true (graphene_point3d_equal (&tmp, &one3)); if (g_test_verbose ()) g_test_message ("Behind the ray..."); graphene_ray_get_position_at (&r, -1.f, &tmp); graphene_assert_fuzzy_equals (tmp.x, 1.f, 0.0001); graphene_assert_fuzzy_equals (tmp.y, 1.f, 0.0001); graphene_assert_fuzzy_equals (tmp.z, 0.f, 0.0001); if (g_test_verbose ()) g_test_message ("On the ray..."); graphene_ray_get_position_at (&r, 1.f, &tmp); graphene_assert_fuzzy_equals (tmp.x, 1.f, 0.0001); graphene_assert_fuzzy_equals (tmp.y, 1.f, 0.0001); graphene_assert_fuzzy_equals (tmp.z, 2.f, 0.0001); }
static void sphere_init (mutest_spec_t *spec) { graphene_point3d_t check; graphene_point3d_t zero = GRAPHENE_POINT3D_INIT_ZERO; graphene_point3d_t one = GRAPHENE_POINT3D_INIT (1, 1, 1); graphene_sphere_t *s; s = graphene_sphere_init (graphene_sphere_alloc (), &one, 1.f); mutest_expect ("alloc to not return null", mutest_pointer (s), mutest_not, mutest_to_be_null, NULL); mutest_expect ("unit sphere not to be empty", mutest_bool_value (graphene_sphere_is_empty (s)), mutest_not, mutest_to_be_true, NULL); graphene_sphere_get_center (s, &check); mutest_expect ("init to set the center", mutest_bool_value (graphene_point3d_equal (&one, &check)), mutest_to_be_true, NULL); mutest_expect ("init to set the radius", mutest_float_value (graphene_sphere_get_radius (s)), mutest_to_be_close_to, 1.0, 0.0001, NULL); graphene_sphere_init (s, NULL, 1.f); graphene_sphere_get_center (s, &check); mutest_expect ("null center to be the origin", mutest_bool_value (graphene_point3d_equal (&zero, &check)), mutest_to_be_true, NULL); graphene_sphere_free (s); }
static void sphere_translate (mutest_spec_t *spec) { graphene_sphere_t s; graphene_point3d_t p; graphene_sphere_init (&s, &GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f), 1.f); graphene_point3d_init (&p, -1.f, -1.f, -1.f); graphene_sphere_translate (&s, &p, &s); graphene_sphere_get_center (&s, &p); mutest_expect ("translating a unit sphere from (1, 1, 1) by -1 puts it at (0, 0, 0)", mutest_bool_value (graphene_point3d_equal (&p, &GRAPHENE_POINT3D_INIT (0.f, 0.f, 0.f))), mutest_to_be_true, NULL); }