mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 13:45:59 +08:00
Added tests for trim_zeroes()
This commit is contained in:
parent
9f83da9519
commit
d18b975195
@ -182,6 +182,8 @@ set(UI_TEST_SOURCES
|
||||
${GUI_TESTDIR}/test_field_choice.cpp
|
||||
${GUI_TESTDIR}/test_field_numchoice.cpp
|
||||
${GUI_TESTDIR}/test_field_point.cpp
|
||||
${GUI_TESTDIR}/test_field_point3.cpp
|
||||
${GUI_TESTDIR}/test_misc_ui.cpp
|
||||
)
|
||||
set(SLIC3R_TEST_SOURCES
|
||||
${TESTDIR}/test_harness.cpp
|
||||
@ -263,6 +265,7 @@ IF(wxWidgets_FOUND)
|
||||
${GUI_LIBDIR}/OptionsGroup/UI_NumChoice.cpp
|
||||
${GUI_LIBDIR}/OptionsGroup/UI_Choice.cpp
|
||||
${GUI_LIBDIR}/OptionsGroup/UI_Point.cpp
|
||||
${GUI_LIBDIR}/OptionsGroup/UI_Point3.cpp
|
||||
)
|
||||
target_compile_features(slic3r_gui PUBLIC cxx_std_14)
|
||||
#only build GUI lib if building with wx
|
||||
|
27
src/test/GUI/test_misc_ui.cpp
Normal file
27
src/test/GUI/test_misc_ui.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <catch.hpp>
|
||||
#include "misc_ui.hpp"
|
||||
#include <string>
|
||||
|
||||
using namespace std::string_literals;
|
||||
using namespace Slic3r::GUI;
|
||||
|
||||
SCENARIO( "trim_zeroes leaves parsable numbers.") {
|
||||
auto n192 {"19.200000000"s};
|
||||
auto n00 {"0.0"s};
|
||||
auto n0 {"0."s};
|
||||
REQUIRE(trim_zeroes(n00) == "0.0"s);
|
||||
REQUIRE(trim_zeroes(n0) == "0.0"s);
|
||||
REQUIRE(trim_zeroes(n192) == "19.2"s);
|
||||
}
|
||||
|
||||
SCENARIO ( "trim_zeroes doesn't reduce precision.") {
|
||||
GIVEN( "A number with a long string of zeroes and a 0") {
|
||||
auto n12 {"19.200000002"s};
|
||||
auto n120 {"19.2000000020"s};
|
||||
auto n1200 {"19.20000000200"s};
|
||||
|
||||
REQUIRE(trim_zeroes(n12) == "19.200000002"s);
|
||||
REQUIRE(trim_zeroes(n120) == "19.200000002"s);
|
||||
REQUIRE(trim_zeroes(n1200) == "19.200000002"s);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user