From 9fbc69e2b6429a787fe82f0d881c2bc78dcfd039 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 26 Jan 2018 11:31:27 -0700 Subject: [PATCH] Add a test. --- tests/base/utilities_pack_unpack_04.cc | 73 ++++++++++++++++++++++ tests/base/utilities_pack_unpack_04.output | 8 +++ 2 files changed, 81 insertions(+) create mode 100644 tests/base/utilities_pack_unpack_04.cc create mode 100644 tests/base/utilities_pack_unpack_04.output diff --git a/tests/base/utilities_pack_unpack_04.cc b/tests/base/utilities_pack_unpack_04.cc new file mode 100644 index 0000000000..7d56b45168 --- /dev/null +++ b/tests/base/utilities_pack_unpack_04.cc @@ -0,0 +1,73 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// test Utilities::pack/unpack on some types. specifically, make sure +// that it works on arrays of primitive types + +#include "../tests.h" + +#include +#include +#include + +#include +#include + + +template +void check (const T (&object)[N]) +{ + const std::vector buffer = Utilities::pack (object); + T unpacked[N]; + Utilities::unpack(buffer, unpacked); + + deallog << "Buffer size check: " << (buffer.size() == sizeof(T)*N ? "OK" : "Failed") << std::endl; + deallog << "memcmp check: " << (std::memcmp(buffer.data(), &object, buffer.size()) == 0 ? "OK" : "Failed") << std::endl; + + bool equal=true; + for (unsigned int i=0; i