]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Address some comments
authorRene Gassmoeller <R.Gassmoeller@mailbox.org>
Wed, 9 Dec 2015 20:30:53 +0000 (14:30 -0600)
committerRene Gassmoeller <R.Gassmoeller@mailbox.org>
Thu, 10 Dec 2015 03:01:42 +0000 (21:01 -0600)
include/deal.II/base/utilities.h
tests/base/utilities_11.cc
tests/base/utilities_11.output

index 8ba7baf461fa8e109e62a553ddaac05932ecf057..1afe8e780bff40ffee16cc5da6a8b49d4a3163f3 100644 (file)
@@ -62,19 +62,21 @@ namespace Utilities
    *
    * @note The use of this function is discouraged and users should use
    * <code>Utilities::to_string()</code> instead. In its current implementation
-   * the function simply calls <code>to_string<unsigned int>()</code>.
+   * the function simply calls <code>to_string@<unsigned int@>()</code>.
    */
   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 <code>lexical_cast<std::string>()</code> had been called.
+   * function <code>lexical_cast@<std::string@>()</code> had been called.
    */
   template <typename number>
   std::string
index d20177393b876d7334853d830168ed8cf58586e7..47686ea42d6e5d98f945f1a8a49f43da6a84544e 100644 (file)
 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;
 }
 
 
index e98c81e962ea29547b886cb253e6c4e2ef8f868c..ba21a93069f54c27ec5abc9f2d755638bae11ee1 100644 (file)
@@ -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.

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.