Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
530e209f
Commit
530e209f
authored
Aug 13, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed async tests to pass TASN checks
parent
566df7e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
test_async.cpp
tests/test_async.cpp
+10
-6
test_sink.h
tests/test_sink.h
+2
-0
No files found.
tests/test_async.cpp
View file @
530e209f
...
...
@@ -26,8 +26,9 @@ TEST_CASE("discard policy ", "[async]")
{
using
namespace
spdlog
;
auto
test_sink
=
std
::
make_shared
<
sinks
::
test_sink_mt
>
();
size_t
queue_size
=
2
;
size_t
messages
=
10240
;
test_sink
->
set_delay
(
std
::
chrono
::
milliseconds
(
1
));
size_t
queue_size
=
4
;
size_t
messages
=
1024
;
auto
tp
=
std
::
make_shared
<
details
::
thread_pool
>
(
queue_size
,
1
);
auto
logger
=
std
::
make_shared
<
async_logger
>
(
"as"
,
test_sink
,
tp
,
async_overflow_policy
::
overrun_oldest
);
...
...
@@ -41,17 +42,20 @@ TEST_CASE("discard policy ", "[async]")
TEST_CASE
(
"discard policy using factory "
,
"[async]"
)
{
using
namespace
spdlog
;
size_t
queue_size
=
2
;
size_t
messages
=
1024
0
;
size_t
queue_size
=
4
;
size_t
messages
=
1024
;
spdlog
::
init_thread_pool
(
queue_size
,
1
);
auto
logger
=
spdlog
::
create_async_nb
<
sinks
::
test_sink_mt
>
(
"as2"
);
auto
test_sink
=
std
::
static_pointer_cast
<
sinks
::
test_sink_mt
>
(
logger
->
sinks
()[
0
]);
test_sink
->
set_delay
(
std
::
chrono
::
milliseconds
(
1
));
for
(
size_t
i
=
0
;
i
<
messages
;
i
++
)
{
logger
->
info
(
"Hello message"
);
}
auto
sink
=
std
::
static_pointer_cast
<
sinks
::
test_sink_mt
>
(
logger
->
sinks
()[
0
]);
REQUIRE
(
sink
->
msg_counter
()
<
messages
);
REQUIRE
(
test_
sink
->
msg_counter
()
<
messages
);
spdlog
::
drop_all
();
}
...
...
tests/test_sink.h
View file @
530e209f
...
...
@@ -21,11 +21,13 @@ class test_sink : public base_sink<Mutex>
public
:
size_t
msg_counter
()
{
std
::
lock_guard
<
Mutex
>
lock
(
base_sink
<
Mutex
>::
mutex_
);
return
msg_counter_
;
}
size_t
flush_counter
()
{
std
::
lock_guard
<
Mutex
>
lock
(
base_sink
<
Mutex
>::
mutex_
);
return
flush_counter_
;
}
...
...
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