diff options
author | enricoturri1966 <enricoturri@seznam.cz> | 2020-03-25 14:07:59 +0300 |
---|---|---|
committer | enricoturri1966 <enricoturri@seznam.cz> | 2020-03-25 14:07:59 +0300 |
commit | a1a4d49f15aab094a0de14f627557cbd6fd46179 (patch) | |
tree | de6f7a76eb3b6d8f1d83ea41c19c70da0ab5b214 /tests | |
parent | 3b6d334d7bb0331e372cde14c69e153810fc0cbe (diff) | |
parent | de06c5d65950965f6a1fa5e55b7875ff9a3e4413 (diff) |
Fixed conflicts after merge with master
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/fff_print/test_data.cpp | 2 | ||||
-rw-r--r-- | tests/fff_print/test_trianglemesh.cpp | 1 | ||||
-rw-r--r-- | tests/libslic3r/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/libslic3r/test_elephant_foot_compensation.cpp | 33 | ||||
-rw-r--r-- | tests/libslic3r/test_timeutils.cpp (renamed from tests/timeutils/timeutils_tests_main.cpp) | 23 | ||||
-rw-r--r-- | tests/slic3rutils/CMakeLists.txt (renamed from tests/timeutils/CMakeLists.txt) | 7 | ||||
-rw-r--r-- | tests/slic3rutils/slic3rutils_tests_main.cpp | 22 |
8 files changed, 62 insertions, 29 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 61fe97277..b91f75be4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,7 +29,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) add_subdirectory(libnest2d) add_subdirectory(libslic3r) -add_subdirectory(timeutils) +add_subdirectory(slic3rutils) add_subdirectory(fff_print) add_subdirectory(sla_print) add_subdirectory(cpp17 EXCLUDE_FROM_ALL) # does not have to be built all the time diff --git a/tests/fff_print/test_data.cpp b/tests/fff_print/test_data.cpp index 50b338325..06f2a6068 100644 --- a/tests/fff_print/test_data.cpp +++ b/tests/fff_print/test_data.cpp @@ -161,7 +161,7 @@ void init_print(std::vector<TriangleMesh> &&meshes, Slic3r::Print &print, Slic3r if (verbose_gcode()) config.set_key_value("gcode_comments", new ConfigOptionBool(true)); - for (const TriangleMesh &t : meshes) { + for (const TriangleMesh &t : meshes) { ModelObject *object = model.add_object(); object->name += "object.stl"; object->add_volume(std::move(t)); diff --git a/tests/fff_print/test_trianglemesh.cpp b/tests/fff_print/test_trianglemesh.cpp index 9598a3c5a..6b467a511 100644 --- a/tests/fff_print/test_trianglemesh.cpp +++ b/tests/fff_print/test_trianglemesh.cpp @@ -277,7 +277,6 @@ SCENARIO( "make_xxx functions produce meshes.") { GIVEN("make_sphere() function") { WHEN("make_sphere() is called with arguments 10, PI / 3") { TriangleMesh sph = make_sphere(10, PI / 243.0); - double angle = (2.0*PI / floor(2.0*PI / (PI / 243.0))); THEN("Resulting mesh has one point at 0,0,-10 and one at 0,0,10") { const std::vector<stl_vertex> &verts = sph.its.vertices; REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return is_approx(t, Vec3f(0.f, 0.f, 10.f)); } ) == 1); diff --git a/tests/libslic3r/CMakeLists.txt b/tests/libslic3r/CMakeLists.txt index d8dac3c10..2353414f9 100644 --- a/tests/libslic3r/CMakeLists.txt +++ b/tests/libslic3r/CMakeLists.txt @@ -13,6 +13,7 @@ add_executable(${_TEST_NAME}_tests test_stl.cpp test_meshsimplify.cpp test_meshboolean.cpp + test_timeutils.cpp ) if (TARGET OpenVDB::openvdb) diff --git a/tests/libslic3r/test_elephant_foot_compensation.cpp b/tests/libslic3r/test_elephant_foot_compensation.cpp index 98ec5df52..616c0c6ad 100644 --- a/tests/libslic3r/test_elephant_foot_compensation.cpp +++ b/tests/libslic3r/test_elephant_foot_compensation.cpp @@ -413,6 +413,19 @@ static ExPolygon contour_with_hole() return out; } +static bool is_valid_orientation(const ExPolygon &p) +{ + bool ret = p.contour.is_counter_clockwise(); + for (auto &h : p.holes) ret = ret && h.is_clockwise(); + return ret; +} + +static bool is_efc_result_smaller(const ExPolygon &efc, const ExPolygon &orig) +{ + double efc_area = efc.area(); + return efc_area > 0. && efc_area < orig.area() && is_valid_orientation(efc); +} + SCENARIO("Elephant foot compensation", "[ElephantFoot]") { GIVEN("Contour with hole") { @@ -426,7 +439,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } @@ -456,7 +469,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } @@ -471,7 +484,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } @@ -523,7 +536,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } WHEN("Fully compensated") { @@ -534,7 +547,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } @@ -549,7 +562,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } @@ -566,7 +579,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } WHEN("Fully compensated") { @@ -577,7 +590,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } WHEN("Brutally compensated") { @@ -588,7 +601,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } @@ -603,7 +616,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } }); #endif /* TESTS_EXPORT_SVGS */ THEN("area of the compensated polygon is smaller") { - REQUIRE(expoly_compensated.area() < expoly.area()); + REQUIRE(is_efc_result_smaller(expoly_compensated, expoly)); } } } diff --git a/tests/timeutils/timeutils_tests_main.cpp b/tests/libslic3r/test_timeutils.cpp index 9989f9871..6630d7055 100644 --- a/tests/timeutils/timeutils_tests_main.cpp +++ b/tests/libslic3r/test_timeutils.cpp @@ -1,4 +1,4 @@ -#include <catch_main.hpp> +#include <catch2/catch.hpp> #include "libslic3r/Time.hpp" @@ -6,45 +6,44 @@ #include <iomanip> #include <locale> -namespace { +using namespace Slic3r; -void test_time_fmt(Slic3r::Utils::TimeFormat fmt) { +static void test_time_fmt(Slic3r::Utils::TimeFormat fmt) { using namespace Slic3r::Utils; time_t t = get_current_time_utc(); - + std::string tstr = time2str(t, TimeZone::local, fmt); time_t parsedtime = str2time(tstr, TimeZone::local, fmt); REQUIRE(t == parsedtime); - + tstr = time2str(t, TimeZone::utc, fmt); parsedtime = str2time(tstr, TimeZone::utc, fmt); REQUIRE(t == parsedtime); - + parsedtime = str2time("not valid string", TimeZone::local, fmt); REQUIRE(parsedtime == time_t(-1)); - + parsedtime = str2time("not valid string", TimeZone::utc, fmt); REQUIRE(parsedtime == time_t(-1)); } -} TEST_CASE("ISO8601Z", "[Timeutils]") { test_time_fmt(Slic3r::Utils::TimeFormat::iso8601Z); - + std::string mydate = "20190710T085000Z"; time_t t = Slic3r::Utils::parse_iso_utc_timestamp(mydate); std::string date = Slic3r::Utils::iso_utc_timestamp(t); - + REQUIRE(date == mydate); } TEST_CASE("Slic3r_UTC_Time_Format", "[Timeutils]") { using namespace Slic3r::Utils; test_time_fmt(TimeFormat::gcode); - + std::string mydate = "2019-07-10 at 08:50:00 UTC"; time_t t = Slic3r::Utils::str2time(mydate, TimeZone::utc, TimeFormat::gcode); std::string date = Slic3r::Utils::utc_timestamp(t); - + REQUIRE(date == mydate); } diff --git a/tests/timeutils/CMakeLists.txt b/tests/slic3rutils/CMakeLists.txt index 6ece9f4d1..f03d8d69a 100644 --- a/tests/timeutils/CMakeLists.txt +++ b/tests/slic3rutils/CMakeLists.txt @@ -1,11 +1,10 @@ get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests_main.cpp - ${PROJECT_SOURCE_DIR}/src/libslic3r/Time.cpp - ${PROJECT_SOURCE_DIR}/src/libslic3r/Time.hpp ) -target_link_libraries(${_TEST_NAME}_tests test_common) + +target_link_libraries(${_TEST_NAME}_tests test_common libslic3r_gui) set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") # catch_discover_tests(${_TEST_NAME}_tests TEST_PREFIX "${_TEST_NAME}: ") -add_test(${_TEST_NAME}_tests ${_TEST_NAME}_tests ${CATCH_EXTRA_ARGS}) +add_test(${_TEST_NAME}_tests ${_TEST_NAME}_tests "${CATCH_EXTRA_ARGS} exclude:[NotWorking]") diff --git a/tests/slic3rutils/slic3rutils_tests_main.cpp b/tests/slic3rutils/slic3rutils_tests_main.cpp new file mode 100644 index 000000000..b82114976 --- /dev/null +++ b/tests/slic3rutils/slic3rutils_tests_main.cpp @@ -0,0 +1,22 @@ +#include <catch_main.hpp> + +#include "slic3r/Utils/Http.hpp" + +TEST_CASE("Http", "[Http][NotWorking]") { + + Slic3r::Http g = Slic3r::Http::get("https://github.com/"); + + unsigned status = 0; + g.on_error([&status](std::string, std::string, unsigned http_status) { + status = http_status; + }); + + g.on_complete([&status](std::string /* body */, unsigned http_status){ + status = http_status; + }); + + g.perform_sync(); + + REQUIRE(status == 200); +} + |