Tests_Detour.cpp 773 B

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