From: Rene Gassmoeller Date: Wed, 9 Dec 2015 20:30:53 +0000 (-0600) Subject: Address some comments X-Git-Tag: v8.4.0-rc2~166^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4b5a99e6f71757af6f75365d41cfc571721ca8e;p=dealii.git Address some comments --- diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h index 8ba7baf461..1afe8e780b 100644 --- a/include/deal.II/base/utilities.h +++ b/include/deal.II/base/utilities.h @@ -62,19 +62,21 @@ namespace Utilities * * @note The use of this function is discouraged and users should use * Utilities::to_string() instead. In its current implementation - * the function simply calls to_string(). + * the function simply calls to_string@(). */ std::string int_to_string (const unsigned int value, const unsigned int digits = numbers::invalid_unsigned_int); /** - * Convert a number @p value to a string, with as many digits as given to fill - * with leading zeros. + * Convert a number @p value to a string, with @p digits characters. + * The string is padded with leading zeros, after a possible minus sign. + * Therefore the total number of padding zeros is @p digits minus any signs, + * decimal points and digits of @p value. * * If the second parameter is left at its default value, the number is not * padded with leading zeros. The result is then the same as if the boost - * function lexical_cast() had been called. + * function lexical_cast@() had been called. */ template std::string diff --git a/tests/base/utilities_11.cc b/tests/base/utilities_11.cc index d20177393b..47686ea42d 100644 --- a/tests/base/utilities_11.cc +++ b/tests/base/utilities_11.cc @@ -28,33 +28,37 @@ 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; + Assert(Utilities::to_string (i)=="8589934592", ExcInternalError()); + Assert(Utilities::to_string (i,11)=="08589934592", ExcInternalError()); unsigned long long j = std::pow(2,31); - deallog << Utilities::to_string (j) << std::endl; + Assert(Utilities::to_string(j)=="2147483648", ExcInternalError()); int k = - std::pow(2,30); - deallog << Utilities::to_string (k) << std::endl; - deallog << Utilities::to_string (k,12) << std::endl; + Assert(Utilities::to_string (k)=="-1073741824", ExcInternalError()); + Assert(Utilities::to_string (k,12)=="-01073741824", ExcInternalError()); long long int l = - std::pow(2,35); - deallog << Utilities::to_string (l) << std::endl; - deallog << Utilities::to_string (l,13) << std::endl; + Assert(Utilities::to_string (l)=="-34359738368", ExcInternalError()); + Assert(Utilities::to_string (l,13)=="-034359738368", ExcInternalError()); float f (-3.14159265358979323846264338327950288419716939937510); - deallog << Utilities::to_string (f) << std::endl; - deallog << Utilities::to_string (f,13) << std::endl; + Assert(Utilities::to_string (f)=="-3.14159274", ExcInternalError()); + Assert(Utilities::to_string (f,13)=="-003.14159274", ExcInternalError()); double d (-3.14159265358979323846264338327950288419716939937510); - deallog << Utilities::to_string (d) << std::endl; - deallog << Utilities::to_string (d,20) << std::endl; + Assert(Utilities::to_string (d)=="-3.1415926535897931", ExcInternalError()); + Assert(Utilities::to_string (d,20)=="-03.1415926535897931", ExcInternalError()); - long double ld (-3.14159265358979323846264338327950288419716939937510); - deallog << Utilities::to_string (ld) << std::endl; - deallog << Utilities::to_string (ld,24) << std::endl; + long double ld (-3.14159265358979323846264338327950288419716939937510L); + Assert(Utilities::to_string (ld)=="-3.14159265358979323851", ExcInternalError()); + Assert(Utilities::to_string (ld,24)=="-03.14159265358979323851", ExcInternalError()); + double ed (-3.1415926535e-115); + Assert(Utilities::to_string (ed)=="-3.1415926534999999e-115", ExcInternalError()); + Assert(Utilities::to_string (ed,24)=="-3.1415926534999999e-115", ExcInternalError()); + deallog << "Ok." << std::endl; } diff --git a/tests/base/utilities_11.output b/tests/base/utilities_11.output index e98c81e962..ba21a93069 100644 --- a/tests/base/utilities_11.output +++ b/tests/base/utilities_11.output @@ -1,14 +1,2 @@ -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 +DEAL::Ok.