From: Daniel Arndt Date: Sat, 27 Jan 2018 23:27:20 +0000 (+0100) Subject: Fix utilities_pack_unpack_03 X-Git-Tag: v9.0.0-rc1~506^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab15de88d4e29edc1e77a3a208effbcebbed1152;p=dealii.git Fix utilities_pack_unpack_03 --- diff --git a/tests/base/utilities_pack_unpack_03.cc b/tests/base/utilities_pack_unpack_03.cc index be7162ce2b..705e98fbf2 100644 --- a/tests/base/utilities_pack_unpack_03.cc +++ b/tests/base/utilities_pack_unpack_03.cc @@ -24,8 +24,7 @@ #include #include -#include -#include +#include 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 @@ -51,22 +50,34 @@ template void check (const T &object) { const std::vector buffer = Utilities::pack (object); - if (!(buffer.size() == sizeof(object)) - || - !(std::memcmp(buffer.data(), &object, buffer.size()) == 0) - || - !(Utilities::unpack(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(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 {{1,2,3}}); + deallog << "struct X:" << std::endl; check (X { 1, 2, 3.1415926 }); - check (std::tuple {1,1,1}); - - deallog << "OK!" << std::endl; + deallog << "double:" << std::endl; + check (1.); } int main() diff --git a/tests/base/utilities_pack_unpack_03.output b/tests/base/utilities_pack_unpack_03.output index 5cfb783b8f..beb17afe94 100644 --- a/tests/base/utilities_pack_unpack_03.output +++ b/tests/base/utilities_pack_unpack_03.output @@ -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::