Commit | Line | Data |
---|---|---|
e3c7d9ac GMF |
1 | /* |
2 | The software in this package is distributed under the GNU General | |
3 | Public License version 2 (with a special exception described below). | |
4 | ||
5 | A copy of GNU General Public License (GPL) is included in this distribution, | |
6 | in the file COPYING.GPL. | |
7 | ||
8 | As a special exception, if other files instantiate templates or use macros | |
9 | or inline functions from this file, or you compile this file and link it | |
10 | with other works to produce a work based on this file, this file | |
11 | does not by itself cause the resulting work to be covered | |
12 | by the GNU General Public License. | |
13 | ||
14 | However the source code for this file must still be made available | |
15 | in accordance with section (3) of the GNU General Public License. | |
16 | ||
17 | This exception does not invalidate any other reasons why a work based | |
18 | on 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 | ||
30 | BOOST_AUTO_TEST_SUITE( TestLogOutput ) | |
31 | ||
32 | BOOST_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 | ||
41 | BOOST_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 | ||
50 | BOOST_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 | ||
59 | BOOST_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 | ||
71 | BOOST_AUTO_TEST_SUITE_END() |