From af74061f79326475a4073fed292ca54c4f5692f3 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Fri, 5 Apr 2019 17:09:19 +0200 Subject: [PATCH] [test][io] Add test for writing double preicison floats to file --- test/io/container/test_container_io.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/io/container/test_container_io.cc b/test/io/container/test_container_io.cc index 36f0bd4986..81bad7eab2 100644 --- a/test/io/container/test_container_io.cc +++ b/test/io/container/test_container_io.cc @@ -38,9 +38,9 @@ namespace Dumux { template<typename T> -bool testContainerIO(const T& c0) +bool testContainerIO(const T& c0, int floatPrecision = 6) { - writeContainerToFile(c0, "container.txt"); + writeContainerToFile(c0, "container.txt", floatPrecision); auto c1 = readFileToContainer<T>("container.txt"); return std::equal(c0.begin(), c0.end(), c1.begin()); } @@ -80,6 +80,11 @@ int main() passed = passed && Dumux::testContainerIO<std::deque<double>>(doublei); if (!passed) return 1; + auto doublepreci = {1.23456789123456, 1.23456789123456, 9.87654321987654}; + passed = passed && Dumux::testContainerIO<std::vector<double>>(doublepreci, 15); + passed = passed && !Dumux::testContainerIO<std::vector<double>>(doublepreci, 7); + if (!passed) return 1; + auto inti = {5, 6, 7, 5, 2, 8}; passed = passed && Dumux::testContainerIO<std::vector<int>>(inti); passed = passed && Dumux::testContainerIO<std::list<int>>(inti); -- GitLab