From 6aa6d85d80763a555cc7f1341efc53b1308b41a2 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Thu, 3 Dec 2015 20:22:35 -0600 Subject: [PATCH] Add test --- tests/base/utilities_11.cc | 71 ++++++++++++++++++++++++++++++++++ tests/base/utilities_11.output | 14 +++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/base/utilities_11.cc create mode 100644 tests/base/utilities_11.output diff --git a/tests/base/utilities_11.cc b/tests/base/utilities_11.cc new file mode 100644 index 0000000000..d20177393b --- /dev/null +++ b/tests/base/utilities_11.cc @@ -0,0 +1,71 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2005 - 2015 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// This tests the implementation of Utilities::to_string for different types. +// Note that the floating point number output might be depend on the system. + +#include "../tests.h" +#include +#include +#include + +#include + + +void test () +{ + unsigned long long int i = std::pow(2,33); + deallog << Utilities::to_string(i) << std::endl; + deallog << Utilities::to_string(i,11) << std::endl; + + unsigned long long j = std::pow(2,31); + deallog << Utilities::to_string (j) << std::endl; + + int k = - std::pow(2,30); + deallog << Utilities::to_string (k) << std::endl; + deallog << Utilities::to_string (k,12) << std::endl; + + long long int l = - std::pow(2,35); + deallog << Utilities::to_string (l) << std::endl; + deallog << Utilities::to_string (l,13) << std::endl; + + float f (-3.14159265358979323846264338327950288419716939937510); + deallog << Utilities::to_string (f) << std::endl; + deallog << Utilities::to_string (f,13) << std::endl; + + double d (-3.14159265358979323846264338327950288419716939937510); + deallog << Utilities::to_string (d) << std::endl; + deallog << Utilities::to_string (d,20) << std::endl; + + long double ld (-3.14159265358979323846264338327950288419716939937510); + deallog << Utilities::to_string (ld) << std::endl; + deallog << Utilities::to_string (ld,24) << std::endl; + + +} + + + + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); +} diff --git a/tests/base/utilities_11.output b/tests/base/utilities_11.output new file mode 100644 index 0000000000..e98c81e962 --- /dev/null +++ b/tests/base/utilities_11.output @@ -0,0 +1,14 @@ + +DEAL::8589934592 +DEAL::08589934592 +DEAL::2147483648 +DEAL::-1073741824 +DEAL::-01073741824 +DEAL::-34359738368 +DEAL::-034359738368 +DEAL::-3.14159274 +DEAL::-003.14159274 +DEAL::-3.1415926535897931 +DEAL::-03.1415926535897931 +DEAL::-3.141592653589793116 +DEAL::-0003.141592653589793116 -- 2.39.5