From: Wolfgang Bangerth Date: Fri, 26 Jan 2018 18:31:27 +0000 (-0700) Subject: Add a test. X-Git-Tag: v9.0.0-rc1~502^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fbc69e2b6429a787fe82f0d881c2bc78dcfd039;p=dealii.git Add a test. --- 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