Kea 2.2.0
wiredata.cc
Go to the documentation of this file.
1// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
10
11#include <gtest/gtest.h>
12
13#include <algorithm> // for std::min
14#include <stdint.h>
15
16using namespace std;
17
18namespace isc {
19namespace util {
20namespace unittests {
21
22void
23matchWireData(const void* expected_data, size_t expected_len,
24 const void* actual_data, size_t actual_len)
25{
26 const size_t cmplen = std::min(expected_len, actual_len);
27
28 for (size_t i = 0; i < cmplen; ++i) {
29 const int ebyte = static_cast<const uint8_t*>(expected_data)[i];
30 const int abyte = static_cast<const uint8_t*>(actual_data)[i];
31 // Once we find a mismatch, it's quite likely that there will be many
32 // mismatches after this point. So we stop here by using ASSERT not
33 // to be too noisy.
34 ASSERT_EQ(ebyte, abyte) << "Wire data mismatch at " << i << "th byte\n"
35 << " Actual: " << abyte << "\n"
36 << "Expected: " << ebyte << "\n";
37 }
38 EXPECT_EQ(expected_len, actual_len)
39 << "Wire data mismatch in length:\n"
40 << " Actual: " << actual_len << "\n"
41 << "Expected: " << expected_len << "\n";
42}
43
44} // unittests
45} // util
46} // isc
void matchWireData(const void *expected_data, size_t expected_len, const void *actual_data, size_t actual_len)
Definition: wiredata.cc:23
Defines the logger used by the top-level component of kea-lfc.
Utilities for tests with wire data.