Kea 2.5.8
wiredata.cc
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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 const size_t cmplen = std::min(expected_len, actual_len);
26 for (size_t i = 0; i < cmplen; ++i) {
27 const int ebyte = static_cast<const uint8_t*>(expected_data)[i];
28 const int abyte = static_cast<const uint8_t*>(actual_data)[i];
29 // Once we find a mismatch, it's quite likely that there will be many
30 // mismatches after this point. So we stop here by using ASSERT not
31 // to be too noisy.
32 ASSERT_EQ(ebyte, abyte) << "Wire data mismatch at " << i << "th byte\n"
33 << " Actual: " << abyte << "\n"
34 << "Expected: " << ebyte << "\n";
35 }
36 EXPECT_EQ(expected_len, actual_len)
37 << "Wire data mismatch in length:\n"
38 << " Actual: " << actual_len << "\n"
39 << "Expected: " << expected_len << "\n";
40}
41
42} // unittests
43} // util
44} // 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.