Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLukas Matena <lukasmatena@seznam.cz>2019-12-12 13:37:33 +0300
committerLukas Matena <lukasmatena@seznam.cz>2019-12-12 13:37:33 +0300
commit537260494df5736b5a36677b86cf04c364fbf831 (patch)
tree838db423c8bc7f4d3594267398c6ad2b2c591d89 /tests
parent135660decfd2cdb6d8b26059c05fa084e399bff2 (diff)
parentc284a65caaa6d859164c33f858512d7d8d3d0f5c (diff)
Merge branch 'master' into lm_tm_hollowing
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/cpp17/CMakeLists.txt9
-rw-r--r--tests/cpp17/main.cpp80
-rw-r--r--tests/libslic3r/test_geometry.cpp36
4 files changed, 126 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f77b4bd25..458d39860 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -27,4 +27,5 @@ add_subdirectory(libslic3r)
add_subdirectory(timeutils)
add_subdirectory(fff_print)
add_subdirectory(sla_print)
+add_subdirectory(cpp17 EXCLUDE_FROM_ALL) # does not have to be built all the time
# add_subdirectory(example)
diff --git a/tests/cpp17/CMakeLists.txt b/tests/cpp17/CMakeLists.txt
new file mode 100644
index 000000000..4e151ecbf
--- /dev/null
+++ b/tests/cpp17/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(Cpp17Test)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+add_executable(cpp17test main.cpp)
+
diff --git a/tests/cpp17/main.cpp b/tests/cpp17/main.cpp
new file mode 100644
index 000000000..f053b4fb4
--- /dev/null
+++ b/tests/cpp17/main.cpp
@@ -0,0 +1,80 @@
+#include <cstdlib>
+#include <iostream>
+#include <tuple>
+#include <string>
+
+// Test new headers in cpp17
+#include <variant>
+#include <optional>
+#include <any>
+#include <string_view>
+
+// Test for nested namespace definition
+namespace PrusaSlicer::Cpp17 {
+
+template<class T> class Foo
+{
+ T m_arg;
+public:
+
+ explicit Foo(T &&arg): m_arg{arg} {}
+};
+
+} // namespace PrusaSlicer::Cpp17
+
+template<class T> std::string get_type(const T &v);
+
+template<> std::string get_type(const int &) { return "int"; }
+template<> std::string get_type(const double &) { return "double"; }
+template<> std::string get_type(const float &) { return "double"; }
+
+int main()
+{
+ // /////////////////////////////////////////////////////////////////////////
+ // Template argument deduction for class templates
+ // /////////////////////////////////////////////////////////////////////////
+
+ auto foo = PrusaSlicer::Cpp17::Foo{1.f};
+
+ // /////////////////////////////////////////////////////////////////////////
+ // Structured bindings:
+ // /////////////////////////////////////////////////////////////////////////
+
+ auto my_tuple = std::make_tuple(0.2, 10);
+
+ auto [a, b] = my_tuple;
+
+ std::cout << "a is " << get_type(a) << std::endl;
+ std::cout << "b is " << get_type(b) << std::endl;
+
+ // /////////////////////////////////////////////////////////////////////////
+ // Test for std::apply()
+ // /////////////////////////////////////////////////////////////////////////
+
+ auto fun = [] (auto a, auto b) {
+ std::cout << "a (" << get_type(a) << ") = " << a << std::endl;
+ std::cout << "b (" << get_type(b) << ") = " << b << std::endl;
+ };
+
+ std::apply(fun, my_tuple);
+
+ // /////////////////////////////////////////////////////////////////////////
+ // constexpr lambda and if
+ // /////////////////////////////////////////////////////////////////////////
+
+ auto isIntegral = [](auto v) constexpr -> bool {
+ if constexpr (std::is_integral_v<decltype(v)>) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ static_assert (isIntegral(10), "" );
+ // would fail to compile: static_assert (isIntegral(10.0), "" );
+
+ std::cout << "Integer is integral: " << isIntegral(0) << std::endl;
+ std::cout << "Floating point is not integral: " << isIntegral(0.0) << std::endl;
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/libslic3r/test_geometry.cpp b/tests/libslic3r/test_geometry.cpp
index 4a800b3d3..6f2bd1c39 100644
--- a/tests/libslic3r/test_geometry.cpp
+++ b/tests/libslic3r/test_geometry.cpp
@@ -263,6 +263,42 @@ SCENARIO("Path chaining", "[Geometry]") {
}
}
}
+ GIVEN("Gyroid infill end points") {
+ Polylines polylines = {
+ { {28122608, 3221037}, {27919139, 56036027} },
+ { {33642863, 3400772}, {30875220, 56450360} },
+ { {34579315, 3599827}, {35049758, 55971572} },
+ { {26483070, 3374004}, {23971830, 55763598} },
+ { {38931405, 4678879}, {38740053, 55077714} },
+ { {20311895, 5015778}, {20079051, 54551952} },
+ { {16463068, 6773342}, {18823514, 53992958} },
+ { {44433771, 7424951}, {42629462, 53346059} },
+ { {15697614, 7329492}, {15350896, 52089991} },
+ { {48085792, 10147132}, {46435427, 50792118} },
+ { {48828819, 10972330}, {49126582, 48368374} },
+ { {9654526, 12656711}, {10264020, 47691584} },
+ { {5726905, 18648632}, {8070762, 45082416} },
+ { {54818187, 39579970}, {52974912, 43271272} },
+ { {4464342, 37371742}, {5027890, 39106220} },
+ { {54139746, 18417661}, {55177987, 38472580} },
+ { {56527590, 32058461}, {56316456, 34067185} },
+ { {3303988, 29215290}, {3569863, 32985633} },
+ { {56255666, 25025857}, {56478310, 27144087} },
+ { {4300034, 22805361}, {3667946, 25752601} },
+ { {8266122, 14250611}, {6244813, 17751595} },
+ { {12177955, 9886741}, {10703348, 11491900} }
+ };
+ Polylines chained = chain_polylines(polylines);
+ THEN("Chained taking the shortest path") {
+ double connection_length = 0.;
+ for (size_t i = 1; i < chained.size(); ++i) {
+ const Polyline &pl1 = chained[i - 1];
+ const Polyline &pl2 = chained[i];
+ connection_length += (pl2.first_point() - pl1.last_point()).cast<double>().norm();
+ }
+ REQUIRE(connection_length < 85206000.);
+ }
+ }
GIVEN("Loop pieces") {
Point a { 2185796, 19058485 };
Point b { 3957902, 18149382 };