Commit | Line | Data |
---|---|---|
7ca853fe 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 | ||
c67aeed7 GMF |
26 | #include <logfunc.hpp> |
27 | ||
7ca853fe GMF |
28 | #include "host/loglevel.h" |
29 | ||
f3c09c5a GMF |
30 | using I2n::Logger::LogLevel; |
31 | ||
7ca853fe GMF |
32 | BOOST_AUTO_TEST_SUITE( TestLogLevel ) |
33 | ||
34 | BOOST_AUTO_TEST_CASE( lowercase ) | |
35 | { | |
d9ce1ade GMF |
36 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "debug" )), static_cast<int>(LogLevel::Debug) ); |
37 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "info" )), static_cast<int>(LogLevel::Info) ); | |
38 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "notice" )), static_cast<int>(LogLevel::Notice) ); | |
39 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "warning" )), static_cast<int>(LogLevel::Warning) ); | |
40 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "error" )), static_cast<int>(LogLevel::Error) ); | |
41 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "critical" )), static_cast<int>(LogLevel::Critical) ); | |
42 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "alert" )), static_cast<int>(LogLevel::Alert) ); | |
43 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "emergency" )), static_cast<int>(LogLevel::Emergency) ); | |
7ca853fe GMF |
44 | } |
45 | ||
46 | BOOST_AUTO_TEST_CASE( uppercase ) | |
47 | { | |
d9ce1ade GMF |
48 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "DEBUG" )), static_cast<int>(LogLevel::Debug) ); |
49 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "INFO" )), static_cast<int>(LogLevel::Info) ); | |
50 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "NOTICE" )), static_cast<int>(LogLevel::Notice) ); | |
51 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "WARNING" )), static_cast<int>(LogLevel::Warning) ); | |
52 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "ERROR" )), static_cast<int>(LogLevel::Error) ); | |
53 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "CRITICAL" )), static_cast<int>(LogLevel::Critical) ); | |
54 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "ALERT" )), static_cast<int>(LogLevel::Alert) ); | |
55 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "EMERGENCY" )), static_cast<int>(LogLevel::Emergency) ); | |
7ca853fe GMF |
56 | } |
57 | ||
58 | BOOST_AUTO_TEST_CASE( mixed_case ) | |
59 | { | |
d9ce1ade GMF |
60 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "DeBuG" )), static_cast<int>(LogLevel::Debug) ); |
61 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "InfO" )), static_cast<int>(LogLevel::Info) ); | |
62 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "NoTicE" )), static_cast<int>(LogLevel::Notice) ); | |
63 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "warNing" )), static_cast<int>(LogLevel::Warning) ); | |
64 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "errOR" )), static_cast<int>(LogLevel::Error) ); | |
65 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "critiCaL" )), static_cast<int>(LogLevel::Critical) ); | |
66 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "aleRt" )), static_cast<int>(LogLevel::Alert) ); | |
67 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "EmerGENCy" )), static_cast<int>(LogLevel::Emergency) ); | |
7ca853fe GMF |
68 | } |
69 | ||
70 | BOOST_AUTO_TEST_CASE( misspelled ) | |
71 | { | |
d9ce1ade GMF |
72 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "when" )), static_cast<int>(LogLevel::Warning) ); |
73 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "the" )), static_cast<int>(LogLevel::Warning) ); | |
74 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "word" )), static_cast<int>(LogLevel::Warning) ); | |
75 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "is" )), static_cast<int>(LogLevel::Warning) ); | |
76 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "wrong" )), static_cast<int>(LogLevel::Warning) ); | |
77 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "stick" )), static_cast<int>(LogLevel::Warning) ); | |
78 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "to" )), static_cast<int>(LogLevel::Warning) ); | |
79 | BOOST_CHECK_EQUAL( static_cast<int>(get_log_level_from_string( "WARNING" )), static_cast<int>(LogLevel::Warning) ); | |
7ca853fe GMF |
80 | } |
81 | ||
82 | BOOST_AUTO_TEST_SUITE_END() |