1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2023-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Kea Hooks Basic
// Commercial End User License Agreement v2.0. See COPYING file in the premium/
// directory.

#include <config.h>

#include <attribute_test.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace isc {
namespace radius {
namespace test {

bool
AttributeTest::compare(ConstAttributePtr first, ConstAttributePtr second) {
    if ((!first && second) || (first && !second)) {
        return (false);
    }
    if (!first && !second) {
        return (true);
    }
    if ((first->getType() != second->getType()) ||
        (first->getValueType() != second->getValueType())) {
        return (false);
    }
    if (first->getValueType() == PW_TYPE_STRING) {
        return (first->toString() == second->toString());
    } else if (first->getValueType() == PW_TYPE_INTEGER) {
        return (first->toInt() == second->toInt());
    } else if (first->getValueType() == PW_TYPE_IPADDR) {
        return (first->toIpAddr() == second->toIpAddr());
    } else if (first->getValueType() == PW_TYPE_IPV6ADDR) {
        return (first->toIpv6Addr() == second->toIpv6Addr());
    } else if (first->getValueType() == PW_TYPE_IPV6PREFIX) {
        return ((first->toIpv6Prefix() == second->toIpv6Prefix()) &&
                (first->toIpv6PrefixLen() == second->toIpv6PrefixLen()));
    }
    // Should not happen...
    return (false);
}

bool
AttributeTest::compare(const Attributes& first, const Attributes& second) {
    auto f = [&](ConstAttributePtr first, ConstAttributePtr second) {
        return (AttributeTest::compare(first, second));
    };
    return (std::equal(first.cbegin(), first.cend(), second.cbegin(), second.cend(), f));
}

} // end of namespace isc::radius::test
} // end of namespace isc::radius
} // end of namespace isc