Update pingcheck to work with cmake 3.28
[pingcheck] / test / test_pingprotocol.cpp
CommitLineData
c5c55889
GMF
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on this file might be covered by the GNU General Public License.
19*/
20
21#define BOOST_TEST_MAIN
22#define BOOST_TEST_DYN_LINK
23
24#include <boost/test/unit_test.hpp>
25
26#include "host/pingprotocol.h"
27
05495299 28BOOST_AUTO_TEST_SUITE( TestPingProtocol )
c5c55889
GMF
29
30BOOST_AUTO_TEST_CASE( lowercase )
31{
32 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "icmp" ), PingProtocol_ICMP );
33 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "tcp" ), PingProtocol_TCP );
34 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "icmpv6" ), PingProtocol_ICMPv6 );
35 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "tcp_ipv6" ), PingProtocol_TCP_IPv6 );
36}
37
38BOOST_AUTO_TEST_CASE( uppercase )
39{
40 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "ICMP" ), PingProtocol_ICMP );
41 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "TCP" ), PingProtocol_TCP );
42 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "ICMPV6" ), PingProtocol_ICMPv6 );
43 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "TCP_IPV6" ), PingProtocol_TCP_IPv6 );
44}
45
46BOOST_AUTO_TEST_CASE( mixed_case )
47{
48 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "IcMp" ), PingProtocol_ICMP );
49 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "TcP" ), PingProtocol_TCP );
50 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "IcmpV6" ), PingProtocol_ICMPv6 );
51 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "Tcp_Ipv6" ), PingProtocol_TCP_IPv6 );
52}
53
54BOOST_AUTO_TEST_CASE( misspelled )
55{
56 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "when" ), PingProtocol_ICMP );
57 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "the" ), PingProtocol_ICMP );
58 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "word" ), PingProtocol_ICMP );
59 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "is" ), PingProtocol_ICMP );
60 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "wrong" ), PingProtocol_ICMP );
61 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "stick" ), PingProtocol_ICMP );
62 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "to" ), PingProtocol_ICMP );
63 BOOST_CHECK_EQUAL( get_ping_protocol_from_string( "ICMP" ), PingProtocol_ICMP );
64}
65
66BOOST_AUTO_TEST_SUITE_END()