feat(thread): add OsTls functions

This commit is contained in:
fallenoak 2022-12-29 22:18:14 -06:00 committed by GitHub
parent 1eb1d281a9
commit e1c516b188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 158 additions and 0 deletions

26
test/Thread.cpp Normal file
View 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);
}
}