From 937f5c6d6aeaa1d17b0b392b6f1f4baff337d0a1 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 21 Jul 2018 23:21:37 -0500 Subject: [PATCH] added tests for setting Config/float values. --- src/test/libslic3r/test_config.cpp | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/libslic3r/test_config.cpp b/src/test/libslic3r/test_config.cpp index 53a53bf61..52389378f 100644 --- a/src/test/libslic3r/test_config.cpp +++ b/src/test/libslic3r/test_config.cpp @@ -105,6 +105,38 @@ SCENARIO("Config accessor functions perform as expected.") { REQUIRE(config->get("octoprint_apikey").getString() == std::to_string(100.5)); } } + WHEN("A float or percent is set as a percent through the string interface.") { + config->set("first_layer_extrusion_width", "100%"); + THEN("Value and percent flag are 100/true") { + auto tmp {config->get("first_layer_extrusion_width")}; + REQUIRE(tmp.percent == true); + REQUIRE(tmp.value == 100); + } + } + WHEN("A float or percent is set as a float through the string interface.") { + config->set("first_layer_extrusion_width", "100"); + THEN("Value and percent flag are 100/false") { + auto tmp {config->get("first_layer_extrusion_width")}; + REQUIRE(tmp.percent == false); + REQUIRE(tmp.value == 100); + } + } + WHEN("A float or percent is set as a float through the int interface.") { + config->set("first_layer_extrusion_width", 100); + THEN("Value and percent flag are 100/false") { + auto tmp {config->get("first_layer_extrusion_width")}; + REQUIRE(tmp.percent == false); + REQUIRE(tmp.value == 100); + } + } + WHEN("A float or percent is set as a float through the double interface.") { + config->set("first_layer_extrusion_width", 100.5); + THEN("Value and percent flag are 100.5/false") { + auto tmp {config->get("first_layer_extrusion_width")}; + REQUIRE(tmp.percent == false); + REQUIRE(tmp.value == 100.5); + } + } WHEN("An invalid option is requested during set.") { THEN("An InvalidOptionType exception is thrown.") { REQUIRE_THROWS_AS(config->set("deadbeef_invalid_option", 1), InvalidOptionType);