40656
|
1 |
/*
|
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
#include "precompiled.hpp"
|
|
25 |
#include "logging/logLevel.hpp"
|
|
26 |
#include "unittest.hpp"
|
|
27 |
|
|
28 |
TEST(LogLevel, from_string) {
|
|
29 |
LogLevelType level;
|
|
30 |
|
|
31 |
// Verify each name defined in the LOG_LEVEL_LIST
|
|
32 |
#define LOG_LEVEL(lname, lstring) \
|
|
33 |
level = LogLevel::from_string(#lstring); \
|
|
34 |
EXPECT_EQ(level, LogLevel::lname);
|
|
35 |
LOG_LEVEL_LIST
|
|
36 |
#undef LOG_LEVEL
|
|
37 |
|
|
38 |
// Verify a few invalid level strings
|
|
39 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string("bad level"));
|
|
40 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string("debugger"));
|
|
41 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string("inf"));
|
|
42 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string("info "));
|
|
43 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string(" info"));
|
|
44 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string("=info"));
|
|
45 |
EXPECT_EQ(LogLevel::Invalid, LogLevel::from_string("infodebugwarning"));
|
|
46 |
}
|
|
47 |
|
|
48 |
TEST(LogLevel, name) {
|
|
49 |
// Use names from macro as reference
|
|
50 |
#define LOG_LEVEL(lname, lstring) \
|
|
51 |
EXPECT_STREQ(LogLevel::name(LogLevel::lname), #lstring);
|
|
52 |
LOG_LEVEL_LIST
|
|
53 |
#undef LOG_LEVEL
|
|
54 |
}
|