Skip to content

Commit

Permalink
Fix bug 0012260: Origin rounding error in saving grid file
Browse files Browse the repository at this point in the history
Added more precision to the base function daWrite3DoubleLine by using STRstd.  Updated testReadWrite3DoubleLine to test the additional precision.
  • Loading branch information
wdolinar committed Mar 11, 2020
1 parent 5f31213 commit 2098471
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions xmscore/dataio/daStreamIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,8 @@ void daWrite3DoubleLine(std::ostream& a_outStream,
const double& a_val2,
const double& a_val3)
{
a_outStream << a_name << ' ' << a_val1 << ' ' << a_val2 << ' ' << a_val3 << '\n';
a_outStream << a_name << ' ' << STRstd(a_val1) << ' ' << STRstd(a_val2) << ' ' << STRstd(a_val3)
<< '\n';
} // daWrite3DoubleLine
//------------------------------------------------------------------------------
/// \brief Write a named integer value to a line.
Expand Down Expand Up @@ -1648,11 +1649,11 @@ void DaStreamIoUnitTests::testReadWrite3DoubleLine()
{
std::ostringstream outputStream;
const char* name = "LINE_NAME";
const double expect1 = 22.1;
const double expect2 = 22.2;
const double expect1 = 560770.5;
const double expect2 = 70055.4;
const double expect3 = 22.3;
daWrite3DoubleLine(outputStream, name, expect1, expect2, expect3);
std::string outputExpected = "LINE_NAME 22.1 22.2 22.3\n";
std::string outputExpected = "LINE_NAME 560770.5 70055.4 22.3\n";
std::string outputFound = outputStream.str();
TS_ASSERT_EQUALS(outputExpected, outputFound);

Expand Down
6 changes: 4 additions & 2 deletions xmscore/testing/TestTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
#include <vector>

// 4. External library headers
//#ifdef CXX_TEST
#ifdef CXX_TEST
#include <cxxtest/TestSuite.h>
//#endif // ifdef CXX_TEST
#else
#error "Should only be included in builds with testing enabled."
#endif // ifdef CXX_TEST

// 5. Shared code headers
#include <xmscore/points/ptsfwd.h>
Expand Down

0 comments on commit 2098471

Please sign in to comment.