Update pingcheck to work with cmake 3.28
[pingcheck] / test / test_logoutput.cpp
CommitLineData
e3c7d9ac
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 <logfunc.hpp>
27
28#include "host/logoutput.h"
29
30BOOST_AUTO_TEST_SUITE( TestLogOutput )
31
32BOOST_AUTO_TEST_CASE( lowercase )
33{
34 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "syslog" )), static_cast<int>(LogOutput_SYSLOG) );
35 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "terminal" )), static_cast<int>(LogOutput_TERMINAL) );
36 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "console" )), static_cast<int>(LogOutput_TERMINAL) );
a85f210b 37 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "stderr" )), static_cast<int>(LogOutput_TERMINAL) );
fda777ea 38 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "file" )), static_cast<int>(LogOutput_FILE) );
e3c7d9ac
GMF
39}
40
41BOOST_AUTO_TEST_CASE( uppercase )
42{
43 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "SYSLOG" )), static_cast<int>(LogOutput_SYSLOG) );
44 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "TERMINAL" )), static_cast<int>(LogOutput_TERMINAL) );
45 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "CONSOLE" )), static_cast<int>(LogOutput_TERMINAL) );
a85f210b 46 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "STDERR" )), static_cast<int>(LogOutput_TERMINAL) );
fda777ea 47 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "FILE" )), static_cast<int>(LogOutput_FILE) );
e3c7d9ac
GMF
48}
49
50BOOST_AUTO_TEST_CASE( mixed_case )
51{
52 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "SysLoG" )), static_cast<int>(LogOutput_SYSLOG) );
53 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "teRmINAl" )), static_cast<int>(LogOutput_TERMINAL) );
54 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "ConSOlE" )), static_cast<int>(LogOutput_TERMINAL) );
a85f210b 55 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "StdErr" )), static_cast<int>(LogOutput_TERMINAL) );
fda777ea 56 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "File" )), static_cast<int>(LogOutput_FILE) );
e3c7d9ac
GMF
57}
58
59BOOST_AUTO_TEST_CASE( misspelled )
60{
a85f210b
CH
61 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "when" )), static_cast<int>(LogOutput_UNDEFINED) );
62 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "the" )), static_cast<int>(LogOutput_UNDEFINED) );
63 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "word" )), static_cast<int>(LogOutput_UNDEFINED) );
64 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "is" )), static_cast<int>(LogOutput_UNDEFINED) );
65 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "wrong" )), static_cast<int>(LogOutput_UNDEFINED) );
66 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "stick" )), static_cast<int>(LogOutput_UNDEFINED) );
67 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "to" )), static_cast<int>(LogOutput_UNDEFINED) );
68 BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "UNDEFINED" )), static_cast<int>(LogOutput_UNDEFINED) );
e3c7d9ac
GMF
69}
70
71BOOST_AUTO_TEST_SUITE_END()