From ab15de88d4e29edc1e77a3a208effbcebbed1152 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 28 Jan 2018 00:27:20 +0100 Subject: [PATCH] Fix utilities_pack_unpack_03 --- tests/base/utilities_pack_unpack_03.cc | 39 ++++++++++++++-------- tests/base/utilities_pack_unpack_03.output | 16 ++++++++- 2 files changed, 40 insertions(+), 15 deletions(-) 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:: -- 2.39.5