-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger_test.cpp
87 lines (76 loc) · 2.51 KB
/
Logger_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "catch.hpp"
#include "../include/Logger.h"
#include <sstream>
using namespace FTS;
TEST_CASE("Message Simple String", "[FTSMSG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(5);
FTSMSG("Testlog", MsgType::Message);
REQUIRE(logout.str() == "Testlog\n");
}
TEST_CASE("Message one integer parameter", "[FTSMSG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(5);
FTSMSG("Testlog {1}", MsgType::Message, toString(123));
REQUIRE(logout.str() == "Testlog 123\n");
}
TEST_CASE("Message three parameter", "[FTSMSG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(5);
FTSMSG("Testlog {1} {3} {2}", MsgType::Message, toString(123), toString(123,0,' ',std::ios::hex), "=");
REQUIRE(logout.str() == "Testlog 123 = 7b\n");
}
TEST_CASE("Warning three parameter", "[FTSMSG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(5);
FTSMSG("Testlog {1} {3} {2}", MsgType::Warning, toString(123), toString(123, 0, ' ', std::ios::hex), "=");
REQUIRE(logout.str() == "Testlog 123 = 7b\n");
}
TEST_CASE("Error message", "[FTSMSG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(5);
FTSMSG("Testlog {1}", MsgType::Error, toString(1));
REQUIRE(logout.str() == "Testlog 1\n");
}
TEST_CASE("Messing missing first parameter placeholder", "[FTSMSG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(5);
FTSMSG("Testlog {3} {2}", MsgType::Warning, toString(123), toString(123, 0, ' ', std::ios::hex), "=");
REQUIRE(logout.str() == "Testlog = 7b\n");
}
TEST_CASE("Debug message same level", "[FTSMSGDBG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(1);
FTSMSGDBG("Testlog {1} {3} {2}", 1, toString(123), toString(123, 0, ' ', std::ios::hex), "=");
REQUIRE(logout.str() == "Testlog 123 = 7b\n");
}
TEST_CASE("Debug message higher level", "[FTSMSGDBG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(1);
FTSMSGDBG("Testlog {1} {3} {2}", 2, toString(123), toString(123, 0, ' ', std::ios::hex), "=");
REQUIRE(logout.str().empty());
}
TEST_CASE("Debug message lower level", "[FTSMSGDBG]")
{
std::stringstream logout;
Logger::LogFile(&logout);
Logger::DbgLevel(2);
FTSMSGDBG("Testlog {1} {3} {2}", 1, toString(123), toString(123, 0, ' ', std::ios::hex), "=");
REQUIRE(logout.str() == "Testlog 123 = 7b\n");
}