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
// Copyright (C) 2023 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 <asiolink/asio_wrapper.h>
#include <asiolink/io_address.h>
#include <icmp_endpoint.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

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

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

using namespace isc::asiolink;
using namespace isc::ping_check;
using namespace std;

// This test checks that the endpoint can manage its own internal
// boost::asio::ip::icmp::endpoint object for IPv4.
TEST(ICMPEndpointTest, v4Address) {
    const string test_address("192.0.2.1");

    IOAddress address(test_address);
    ICMPEndpoint endpoint(address);

    EXPECT_TRUE(address == endpoint.getAddress());
    EXPECT_EQ(static_cast<short>(IPPROTO_ICMP), endpoint.getProtocol());
    EXPECT_EQ(AF_INET, endpoint.getFamily());
}

// This test checks that the endpoint can manage its own internal
// boost::asio::ip::icmp::endpoint object for IPv6.
TEST(ICMPEndpointTest, v6Address) {
    const string test_address("2001:db8::1235");

    IOAddress address(test_address);
    ICMPEndpoint endpoint(address);

    EXPECT_TRUE(address == endpoint.getAddress());
    EXPECT_EQ(static_cast<short>(IPPROTO_ICMPV6), endpoint.getProtocol());
    EXPECT_EQ(AF_INET6, endpoint.getFamily());
}