test_utils.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include <catch2/catch.hpp>
  2. #include "libslic3r/libslic3r.h"
  3. SCENARIO("Test fast_round_up()") {
  4. using namespace Slic3r;
  5. THEN("fast_round_up<int>(1.5) is 2") {
  6. REQUIRE(fast_round_up<int>(1.5) == 2);
  7. }
  8. THEN("fast_round_up<int>(1.499999999999999) is 1") {
  9. REQUIRE(fast_round_up<int>(1.499999999999999) == 1);
  10. }
  11. THEN("fast_round_up<int>(0.5) is 1") {
  12. REQUIRE(fast_round_up<int>(0.5) == 1);
  13. }
  14. THEN("fast_round_up<int>(0.49999999999999994) is 0") {
  15. REQUIRE(fast_round_up<int>(0.49999999999999994) == 0);
  16. }
  17. THEN("fast_round_up<int>(-0.5) is 0") {
  18. REQUIRE(fast_round_up<int>(-0.5) == 0);
  19. }
  20. THEN("fast_round_up<int>(-0.51) is -1") {
  21. REQUIRE(fast_round_up<int>(-0.51) == -1);
  22. }
  23. THEN("fast_round_up<int>(-0.51) is -1") {
  24. REQUIRE(fast_round_up<int>(-0.51) == -1);
  25. }
  26. THEN("fast_round_up<int>(-1.5) is -1") {
  27. REQUIRE(fast_round_up<int>(-1.5) == -1);
  28. }
  29. THEN("fast_round_up<int>(-1.51) is -2") {
  30. REQUIRE(fast_round_up<int>(-1.51) == -2);
  31. }
  32. }