diff --git a/src/value.cc b/src/value.cc index ab78c2a0..5ea766c1 100644 --- a/src/value.cc +++ b/src/value.cc @@ -363,7 +363,20 @@ std::string Value::toString() const << ']'; break; case NUMBER: +#ifdef OPENSCAD_TESTING + // Quick and dirty hack to work around floating point rounding differences + // across platforms for testing purposes. + { + std::stringstream tmp; + tmp.precision(16); + tmp << this->num; + std::string tmpstr = tmp.str(); + if (tmpstr.size() > 16) tmpstr.erase(16); + stream << tmpstr; + } +#else stream << this->num; +#endif break; case BOOL: stream << (this->b ? "true" : "false"); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 15f168fe..6de3d938 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -199,6 +199,7 @@ include_directories(${CGAL_INCLUDE_DIRS}) include_directories(../src) add_definitions(-DOPENSCAD_VERSION=test -DOPENSCAD_YEAR=2011 -DOPENSCAD_MONTH=10) +add_definitions(-DOPENSCAD_TESTING) set(CORE_SOURCES tests-common.cc diff --git a/tests/regression/echotest/builtin-tests-expected.txt b/tests/regression/echotest/builtin-tests-expected.txt index e8b2027a..0e8d1a74 100644 --- a/tests/regression/echotest/builtin-tests-expected.txt +++ b/tests/regression/echotest/builtin-tests-expected.txt @@ -1 +1 @@ -ECHO: 3.141592653589793 +ECHO: 3.14159265358979 diff --git a/tests/regression/echotest/dim-all-expected.txt b/tests/regression/echotest/dim-all-expected.txt index 74044a17..d8c32694 100644 --- a/tests/regression/echotest/dim-all-expected.txt +++ b/tests/regression/echotest/dim-all-expected.txt @@ -1,16 +1,16 @@ WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: linearX = 51.44957554275265 +ECHO: linearX = 51.4495755427526 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: linearY = 29.13025467434841 +ECHO: linearY = 29.1302546743484 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: aligned = 60.00000000000001 +ECHO: aligned = 60.0000000000000 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: ordinateX = -49.17542445724735 +ECHO: ordinateX = -49.175424457247 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: ordinateY = 30.86974532565159 +ECHO: ordinateY = 30.8697453256515 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. ECHO: radius = 60 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. ECHO: diameter = 120 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: arc = 59.03624346792648 +ECHO: arc = 59.0362434679264