tests: avoid misaligned memory access in CS test
refs #4191
Change-Id: Idbc59c7d64805f6af239d66635821647956daf6d
diff --git a/tests/daemon/table/cs.t.cpp b/tests/daemon/table/cs.t.cpp
index 7951b02..3aa6de4 100644
--- a/tests/daemon/table/cs.t.cpp
+++ b/tests/daemon/table/cs.t.cpp
@@ -24,11 +24,13 @@
*/
#include "table/cs.hpp"
-#include <ndn-cxx/lp/tags.hpp>
-#include <ndn-cxx/util/sha256.hpp>
#include "tests/test-common.hpp"
+#include <cstring>
+#include <ndn-cxx/lp/tags.hpp>
+#include <ndn-cxx/util/sha256.hpp>
+
#define CHECK_CS_FIND(expected) find([&] (uint32_t found) { BOOST_CHECK_EQUAL(expected, found); });
namespace nfd {
@@ -74,7 +76,8 @@
[&] (const Interest& interest, const Data& data) {
hasResult = true;
const Block& content = data.getContent();
- uint32_t found = *reinterpret_cast<const uint32_t*>(content.value());
+ uint32_t found = 0;
+ std::memcpy(&found, content.value(), sizeof(found));
check(found);
},
bind([&] {