Attempt to batte floating point rounding differences for testing purposes

stl_dim
Marius Kintel 2011-11-24 23:10:46 +01:00
parent 3f0a991a3d
commit 42d7099089
4 changed files with 21 additions and 7 deletions

View File

@ -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");

View File

@ -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

View File

@ -1 +1 @@
ECHO: 3.141592653589793
ECHO: 3.14159265358979

View File

@ -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