Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f3c23332
authored
Mar 09, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base_cpp: fixed log test
parent
900bc329
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
56 deletions
+45
-56
base_cpp/test/log_test.cc
+45
-56
No files found.
base_cpp/test/log_test.cc
View file @
f3c23332
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include <embb/base/c/internal/unused.h>
#include <embb/base/c/internal/unused.h>
#include <embb/base/log.h>
#include <embb/base/log.h>
#include <
c
string>
#include <string>
namespace
embb
{
namespace
embb
{
namespace
base
{
namespace
base
{
...
@@ -38,7 +38,7 @@ LogTest::LogTest() {
...
@@ -38,7 +38,7 @@ LogTest::LogTest() {
CreateUnit
(
"Test all"
).
Add
(
&
LogTest
::
Test
,
this
);
CreateUnit
(
"Test all"
).
Add
(
&
LogTest
::
Test
,
this
);
}
}
static
char
const
*
logged_message
;
static
std
::
string
logged_message
;
static
void
test_log_function
(
void
*
context
,
char
const
*
msg
)
{
static
void
test_log_function
(
void
*
context
,
char
const
*
msg
)
{
EMBB_UNUSED
(
context
);
EMBB_UNUSED
(
context
);
...
@@ -48,101 +48,90 @@ static void test_log_function(void * context, char const * msg) {
...
@@ -48,101 +48,90 @@ static void test_log_function(void * context, char const * msg) {
void
LogTest
::
Test
()
{
void
LogTest
::
Test
()
{
using
embb
::
base
::
Log
;
using
embb
::
base
::
Log
;
char
const
*
test_msg
=
"hello"
;
char
const
*
test_msg
=
"hello"
;
char
const
*
null
=
0
;
Log
::
SetLogFunction
(
0
,
test_log_function
);
Log
::
SetLogFunction
(
0
,
test_log_function
);
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_TRACE
);
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_TRACE
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Trace
(
"chn"
,
test_msg
);
Log
::
Trace
(
"chn"
,
test_msg
);
#ifdef EMBB_DEBUG
#ifdef EMBB_DEBUG
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [TRACE] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [TRACE] hello"
));
#else
#else
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
#endif
#endif
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Info
(
"chn"
,
test_msg
);
Log
::
Info
(
"chn"
,
test_msg
);
#ifdef EMBB_DEBUG
#ifdef EMBB_DEBUG
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [INFO ] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [INFO ] hello"
));
#else
#else
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
#endif
#endif
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Warning
(
"chn"
,
test_msg
);
Log
::
Warning
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [WARN ] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [WARN ] hello"
));
logged_message
=
"none"
;
logged_message
=
null
;
Log
::
Error
(
"chn"
,
test_msg
);
Log
::
Error
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [ERROR] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [ERROR] hello"
));
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_INFO
);
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_INFO
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Trace
(
"chn"
,
test_msg
);
Log
::
Trace
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Info
(
"chn"
,
test_msg
);
Log
::
Info
(
"chn"
,
test_msg
);
#ifdef EMBB_DEBUG
#ifdef EMBB_DEBUG
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [INFO ] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [INFO ] hello"
));
#else
#else
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
#endif
#endif
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Warning
(
"chn"
,
test_msg
);
Log
::
Warning
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [WARN ] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [WARN ] hello"
));
logged_message
=
"none"
;
logged_message
=
null
;
Log
::
Error
(
"chn"
,
test_msg
);
Log
::
Error
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [ERROR] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [ERROR] hello"
));
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_WARNING
);
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_WARNING
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Trace
(
"chn"
,
test_msg
);
Log
::
Trace
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Info
(
"chn"
,
test_msg
);
Log
::
Info
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Warning
(
"chn"
,
test_msg
);
Log
::
Warning
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [WARN ] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [WARN ] hello"
));
logged_message
=
"none"
;
logged_message
=
null
;
Log
::
Error
(
"chn"
,
test_msg
);
Log
::
Error
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [ERROR] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [ERROR] hello"
));
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_ERROR
);
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_ERROR
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Trace
(
"chn"
,
test_msg
);
Log
::
Trace
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Info
(
"chn"
,
test_msg
);
Log
::
Info
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Warning
(
"chn"
,
test_msg
);
Log
::
Warning
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Error
(
"chn"
,
test_msg
);
Log
::
Error
(
"chn"
,
test_msg
);
PT_ASSERT_NE
(
logged_message
,
null
);
PT_EXPECT
(
logged_message
==
"[chn] - [ERROR] hello"
);
PT_EXPECT
(
0
==
strcmp
(
logged_message
,
"[chn] - [ERROR] hello"
));
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_NONE
);
Log
::
SetLogLevel
(
EMBB_LOG_LEVEL_NONE
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Trace
(
"chn"
,
test_msg
);
Log
::
Trace
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Info
(
"chn"
,
test_msg
);
Log
::
Info
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Warning
(
"chn"
,
test_msg
);
Log
::
Warning
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
logged_message
=
null
;
logged_message
=
"none"
;
Log
::
Error
(
"chn"
,
test_msg
);
Log
::
Error
(
"chn"
,
test_msg
);
PT_EXPECT
_EQ
(
null
,
logged_message
);
PT_EXPECT
(
logged_message
==
"none"
);
}
}
}
// namespace test
}
// namespace test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment