Skip to content

Commit b25e6e7

Browse files
tobiasherzketstenner
authored andcommitted
Test thread-local storage in loguru library
1 parent 74c780d commit b25e6e7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

testing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ find_package(Threads REQUIRED)
3232

3333
add_executable(lsl_test_internal
3434
test_int_inireader.cpp
35+
test_int_loguruthreadnames.cpp
3536
test_int_network.cpp
3637
test_int_stringfuncs.cpp
3738
test_int_streaminfo.cpp
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <loguru.hpp>
2+
#include <thread>
3+
4+
#include <catch2/catch.hpp>
5+
6+
TEST_CASE("loguru_thread_local_storage", "[threading]") {
7+
char name[2] = "0";
8+
loguru::set_thread_name("1");
9+
std::thread([&](){
10+
loguru::set_thread_name("2");
11+
loguru::get_thread_name(name,2,false);
12+
}).join();
13+
REQUIRE(name[0] == '2');
14+
loguru::get_thread_name(name,2,false);
15+
REQUIRE(name[0] == '1');
16+
}

0 commit comments

Comments
 (0)