mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
feat(thread): add OsTls functions
This commit is contained in:
parent
1eb1d281a9
commit
e1c516b188
5 changed files with 158 additions and 0 deletions
26
test/Thread.cpp
Normal file
26
test/Thread.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "common/Thread.hpp"
|
||||
#include "test/Test.hpp"
|
||||
|
||||
TEST_CASE("OsTlsAlloc", "[thread]") {
|
||||
SECTION("allocates tls index") {
|
||||
int32_t tlsIndex = OsTlsAlloc();
|
||||
REQUIRE(tlsIndex >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("OsTlsSetValue", "[thread]") {
|
||||
SECTION("sets value in tls index") {
|
||||
int32_t tlsIndex = OsTlsAlloc();
|
||||
uint32_t tlsValue = 123;
|
||||
REQUIRE(OsTlsSetValue(tlsIndex, &tlsValue));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("OsTlsGetValue", "[thread]") {
|
||||
SECTION("gets value in tls index") {
|
||||
int32_t tlsIndex = OsTlsAlloc();
|
||||
uint32_t tlsValue = 456;
|
||||
OsTlsSetValue(tlsIndex, &tlsValue);
|
||||
REQUIRE(OsTlsGetValue(tlsIndex) == &tlsValue);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue