| 1 | #include "catch2/catch_all.hpp" |
| 2 | |
| 3 | #include "DetourCommon.h" |
| 4 | |
| 5 | TEST_CASE("dtRandomPointInConvexPoly") |
| 6 | { |
| 7 | SECTION("Properly works when the argument 's' is 1.0f") |
| 8 | { |
| 9 | const float pts[] = { |
| 10 | 0, 0, 0, |
| 11 | 0, 0, 1, |
| 12 | 1, 0, 0, |
| 13 | }; |
| 14 | const int npts = 3; |
| 15 | float areas[6]; |
| 16 | float out[3]; |
| 17 | |
| 18 | dtRandomPointInConvexPoly(pts, npts, areas, 0.0f, 1.0f, out); |
| 19 | REQUIRE(out[0] == Catch::Approx(0)); |
| 20 | REQUIRE(out[1] == Catch::Approx(0)); |
| 21 | REQUIRE(out[2] == Catch::Approx(1)); |
| 22 | |
| 23 | dtRandomPointInConvexPoly(pts, npts, areas, 0.5f, 1.0f, out); |
| 24 | REQUIRE(out[0] == Catch::Approx(1.0f / 2)); |
| 25 | REQUIRE(out[1] == Catch::Approx(0)); |
| 26 | REQUIRE(out[2] == Catch::Approx(1.0f / 2)); |
| 27 | |
| 28 | dtRandomPointInConvexPoly(pts, npts, areas, 1.0f, 1.0f, out); |
| 29 | REQUIRE(out[0] == Catch::Approx(1)); |
| 30 | REQUIRE(out[1] == Catch::Approx(0)); |
| 31 | REQUIRE(out[2] == Catch::Approx(0)); |
| 32 | } |
| 33 | } |