mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
27 lines
693 B
C++
27 lines
693 B
C++
|
|
#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);
|
||
|
|
}
|
||
|
|
}
|