Skip to content

Commit 6289943

Browse files
committed
Improve test fixture.
1 parent 3b8dc59 commit 6289943

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tests/logging.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ using namespace std::literals;
1818

1919
struct LoggingTest : public ::testing::Test {
2020
LoggingTest() : _log{"test.log", std::ios::trunc} {
21-
ext::logging::configuration::stream = &_log;
21+
using namespace ext::logging;
22+
configuration::stream = &_log;
23+
configuration::gdb = false;
24+
configuration::vim = false;
25+
configuration::prefix_newline = false;
26+
configuration::append_newline = true;
27+
set_level_all(level::EXT_LOGGING_DEFAULT_LEVEL);
2228
};
2329

2430

@@ -52,8 +58,6 @@ TEST_F(LoggingTest, logging_no_crash_gdb_vim) {
5258
using namespace ext::logging;
5359
configuration::gdb = true;
5460
configuration::vim = true;
55-
configuration::prefix_newline = false;
56-
configuration::append_newline = true;
5761

5862
_line = __LINE__ + 1;
5963
ASSERT_NO_THROW(EXT_LOG("babe") << "cafe?");
@@ -67,8 +71,6 @@ TEST_F(LoggingTest, logging_no_crash_gdb_vim) {
6771

6872
TEST_F(LoggingTest, logging_no_crash) {
6973
using namespace ext::logging;
70-
configuration::gdb = false;
71-
configuration::vim = false;
7274
configuration::prefix_newline = true;
7375
configuration::append_newline = false;
7476

@@ -78,28 +80,16 @@ TEST_F(LoggingTest, logging_no_crash) {
7880
}
7981

8082
TEST_F(LoggingTest, logging_level_too_low) {
81-
using namespace ext::logging;
82-
configuration::gdb = false;
83-
configuration::vim = false;
84-
configuration::prefix_newline = true;
85-
configuration::append_newline = false;
86-
topic::network.activation_level = level::error;
87-
83+
ext::logging::topic::network.activation_level = ext::logging::level::error;
8884
_line = __LINE__ + 1;
8985
ASSERT_NO_THROW(EXT_LOG("music", network, warn) << "Green" << "Day");
9086
compare("");
9187
}
9288

9389
TEST_F(LoggingTest, logging_level_ok) {
94-
using namespace ext::logging;
95-
configuration::gdb = false;
96-
configuration::vim = false;
97-
configuration::prefix_newline = true;
98-
configuration::append_newline = false;
99-
10090
_line = __LINE__ + 1;
10191
ASSERT_NO_THROW(EXT_LOG("music", network, error) << "Green" << " Day");
102-
compare("\n[music] error (network) logging.cpp:" + line() +" in TestBody(): 'Green Day'");
92+
compare("[music] error (network) logging.cpp:" + line() +" in TestBody(): 'Green Day'\n");
10393
}
10494

10595
// does not die

0 commit comments

Comments
 (0)