Browse Source

refactor: use compare_vec3 for 3-component assertions

test-refactor
cinnaboot 2 months ago
parent
commit
137e45121a
  1. 12
      tests/test_physics_utilities.cpp

12
tests/test_physics_utilities.cpp

@ -12,23 +12,17 @@ SCENARIO("Vector math utilities", "[physics][utilities][vector]") {
SECTION("add") { SECTION("add") {
const Vec3 sum = vec3_add(a, b); const Vec3 sum = vec3_add(a, b);
REQUIRE_THAT(sum.x, WithinAbs(5.0, R_TOL)); REQUIRE(compare_vec3(sum, {5.0, 7.0, 9.0}, R_TOL));
REQUIRE_THAT(sum.y, WithinAbs(7.0, R_TOL));
REQUIRE_THAT(sum.z, WithinAbs(9.0, R_TOL));
} }
SECTION("sub") { SECTION("sub") {
const Vec3 diff = vec3_sub(b, a); const Vec3 diff = vec3_sub(b, a);
REQUIRE_THAT(diff.x, WithinAbs(3.0, R_TOL)); REQUIRE(compare_vec3(diff, {3.0, 3.0, 3.0}, R_TOL));
REQUIRE_THAT(diff.y, WithinAbs(3.0, R_TOL));
REQUIRE_THAT(diff.z, WithinAbs(3.0, R_TOL));
} }
SECTION("scale") { SECTION("scale") {
const Vec3 scaled = vec3_scale(a, 2.0); const Vec3 scaled = vec3_scale(a, 2.0);
REQUIRE_THAT(scaled.x, WithinAbs(2.0, R_TOL)); REQUIRE(compare_vec3(scaled, {2.0, 4.0, 6.0}, R_TOL));
REQUIRE_THAT(scaled.y, WithinAbs(4.0, R_TOL));
REQUIRE_THAT(scaled.z, WithinAbs(6.0, R_TOL));
} }
SECTION("magnitude") { SECTION("magnitude") {

Loading…
Cancel
Save