// McpTools.hpp reaches wx's MSW headers through GLCanvas3D.hpp after OCCT has hidden the USER and GDI // declarations they need; the Windows headers first keep them, as in test_plugin_host_api.cpp. #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include #include #endif #include #include "slic3r/GUI/Mcp/McpTools.hpp" #include "slic3r/GUI/Mcp/McpTypes.hpp" #include "libslic3r/Config.hpp" #include "libslic3r/Point.hpp" #include #include #include using namespace Slic3r::GUI::Mcp; using nlohmann::json; TEST_CASE("setting values serialize the way their options read them back", "[Mcp]") { CHECK(to_config_string(json(3)) == "3"); CHECK(to_config_string(json(0.2)) == "0.2"); CHECK(to_config_string(json(true)) == "1"); CHECK(to_config_string(json("15%")) == "15%"); CHECK(to_config_string(json::array({0.4, 0.6}), "nozzle_diameter") == "0.4,0.6"); // A list of strings whose entries contain the separators survives the round trip. const std::vector scripts{"/usr/bin/fix --mode=a,b", "second; with a semicolon"}; Slic3r::ConfigOptionStrings parsed; parsed.deserialize(to_config_string(json(scripts), "post_process")); CHECK(parsed.values == scripts); // Points as [x, y] pairs, or already in OrcaSlicer's "XxY" form. const json area = json::array({json::array({0, 0}), json::array({220.5, 0}), "220x220", json::array({0, 220})}); Slic3r::ConfigOptionPoints points; REQUIRE(points.deserialize(to_config_string(area, "printable_area"))); REQUIRE(points.values.size() == 4); CHECK(points.values[1] == Slic3r::Vec2d(220.5, 0)); CHECK(points.values[2] == Slic3r::Vec2d(220, 220)); CHECK(to_config_string(json::array({10, 20}), "bed_mesh_min") == "10x20"); // A string is already in OrcaSlicer's format, list options included. CHECK(to_config_string(json("a.py;b.py"), "post_process") == "a.py;b.py"); CHECK_THROWS_AS(to_config_string(json::object()), ToolFailure); }