]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix utilities_pack_unpack_03 5821/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 27 Jan 2018 23:27:20 +0000 (00:27 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 27 Jan 2018 23:27:20 +0000 (00:27 +0100)
tests/base/utilities_pack_unpack_03.cc
tests/base/utilities_pack_unpack_03.output

index be7162ce2bb2f550b2ca32e68d59e1f31d711926..705e98fbf295752f361569b8d7dd05ad6f8f5674 100644 (file)
@@ -24,8 +24,7 @@
 #include <deal.II/base/point.h>
 #include <boost/serialization/utility.hpp>
 
-#include <tuple>
-#include <cstring>
+#include <array>
 
 struct X
 {
@@ -33,9 +32,9 @@ struct X
   int k;
   double d;
 
-  bool operator == (const X &x) const
+  bool operator != (const X &x) const
   {
-    return i==x.i && k==x.k && d==x.d;
+    return i!=x.i || k!=x.k || d!=x.d;
   }
 
   template <class Archive>
@@ -51,22 +50,34 @@ template <typename T>
 void check (const T &object)
 {
   const std::vector<char> buffer = Utilities::pack (object);
-  if (!(buffer.size() == sizeof(object))
-      ||
-      !(std::memcmp(buffer.data(), &object, buffer.size()) == 0)
-      ||
-      !(Utilities::unpack<T>(buffer) == object))
-    deallog << "Fail!" << std::endl;
+  if (buffer.size() != sizeof(object))
+    deallog << buffer.size() << " should be "
+            << sizeof(object) << "!" << std::endl;
+  else
+    deallog << "same size!" << std::endl;
+
+  if (std::memcmp(buffer.data(), &object, buffer.size()) != 0)
+    deallog << "std::memcmp failed!" << std::endl;
+  else
+    deallog << "std::memcmp passed!" << std::endl;
+
+  if (Utilities::unpack<T>(buffer) != object)
+    deallog << "Comparing the objects failed!" << std::endl;
+  else
+    deallog << "Comparing the objects passed!" << std::endl;
+
+  deallog << std::endl;
 }
 
 
 void test()
 {
-  check (std::make_pair(1, 3.14));
+  deallog << "std::array:" << std::endl;
+  check (std::array<int,3> {{1,2,3}});
+  deallog << "struct X:" << std::endl;
   check (X { 1, 2, 3.1415926 });
-  check (std::tuple<int,double,char> {1,1,1});
-
-  deallog << "OK!" << std::endl;
+  deallog << "double:" << std::endl;
+  check (1.);
 }
 
 int main()
index 5cfb783b8f8be55fd1e5d71f5451a4c660f6427b..beb17afe947de63734ffaafc7e6fa8bc5acb4421 100644 (file)
@@ -1,2 +1,16 @@
 
-DEAL::OK!
+DEAL::std::array:
+DEAL::same size!
+DEAL::std::memcmp passed!
+DEAL::Comparing the objects passed!
+DEAL::
+DEAL::struct X:
+DEAL::same size!
+DEAL::std::memcmp passed!
+DEAL::Comparing the objects passed!
+DEAL::
+DEAL::double:
+DEAL::same size!
+DEAL::std::memcmp passed!
+DEAL::Comparing the objects passed!
+DEAL::

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.