Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
98e151fd
Commit
98e151fd
authored
Jun 27, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for dup_filter sink
parent
7f3b5fb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
1 deletion
+79
-1
tests/CMakeLists.txt
tests/CMakeLists.txt
+2
-1
tests/test_dup_filter.cpp
tests/test_dup_filter.cpp
+77
-0
No files found.
tests/CMakeLists.txt
View file @
98e151fd
...
...
@@ -14,7 +14,8 @@ set(SPDLOG_UTESTS_SOURCES
test_mpmc_q.cpp
test_sink.h
test_fmt_helper.cpp
test_stdout_api.cpp
)
test_stdout_api.cpp
test_dup_filter.cpp
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/logs"
)
enable_testing
()
...
...
tests/test_dup_filter.cpp
0 → 100644
View file @
98e151fd
#include "includes.h"
#include "spdlog/sinks/dup_filter_sink.h"
#include "test_sink.h"
using
namespace
spdlog
;
using
namespace
spdlog
::
sinks
;
TEST_CASE
(
"dup_filter_test1"
,
"[dup_filter_sink]"
)
{
dup_filter_sink_st
dup_sink
{
std
::
chrono
::
seconds
{
5
}};
auto
test_sink
=
std
::
make_shared
<
test_sink_mt
>
();
dup_sink
.
add_sink
(
test_sink
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message1"
});
}
REQUIRE
(
test_sink
->
msg_counter
()
==
1
);
}
TEST_CASE
(
"dup_filter_test2"
,
"[dup_filter_sink]"
)
{
dup_filter_sink_st
dup_sink
{
std
::
chrono
::
seconds
{
0
}};
auto
test_sink
=
std
::
make_shared
<
test_sink_mt
>
();
dup_sink
.
add_sink
(
test_sink
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message1"
});
}
REQUIRE
(
test_sink
->
msg_counter
()
==
10
);
}
TEST_CASE
(
"dup_filter_test3"
,
"[dup_filter_sink]"
)
{
dup_filter_sink_st
dup_sink
{
std
::
chrono
::
seconds
{
0
}};
auto
test_sink
=
std
::
make_shared
<
test_sink_mt
>
();
dup_sink
.
add_sink
(
test_sink
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message1"
});
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message2"
});
}
REQUIRE
(
test_sink
->
msg_counter
()
==
20
);
}
TEST_CASE
(
"dup_filter_test4"
,
"[dup_filter_sink]"
)
{
dup_filter_sink_st
dup_sink
{
std
::
chrono
::
milliseconds
{
10
}};
auto
test_sink
=
std
::
make_shared
<
test_sink_mt
>
();
dup_sink
.
add_sink
(
test_sink
);
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message"
});
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
50
));
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message"
});
REQUIRE
(
test_sink
->
msg_counter
()
==
2
);
}
TEST_CASE
(
"dup_filter_test5"
,
"[dup_filter_sink]"
)
{
dup_filter_sink_st
dup_sink
{
std
::
chrono
::
seconds
{
5
}};
auto
test_sink
=
std
::
make_shared
<
test_sink_mt
>
();
dup_sink
.
add_sink
(
test_sink
);
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message1"
});
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message1"
});
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message1"
});
dup_sink
.
log
(
spdlog
::
details
::
log_msg
{
"test"
,
spdlog
::
level
::
info
,
"message2"
});
REQUIRE
(
test_sink
->
msg_counter
()
==
3
);
// skip 2 messages but log the "skipped.." message before message2
}
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