mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#include "storm/Thread.hpp"
|
|
#include <bc/Memory.hpp>
|
|
#include "test/Test.hpp"
|
|
|
|
uint32_t threadProc(void* param) {
|
|
return 0;
|
|
};
|
|
|
|
TEST_CASE("CCritSect::Enter", "[thread]") {
|
|
SECTION("locks critical section") {
|
|
CCritSect critSect;
|
|
critSect.Enter();
|
|
SUCCEED();
|
|
}
|
|
}
|
|
|
|
TEST_CASE("CCritSect::Leave", "[thread]") {
|
|
SECTION("unlocks critical section") {
|
|
CCritSect critSect;
|
|
critSect.Enter();
|
|
critSect.Leave();
|
|
SUCCEED();
|
|
}
|
|
}
|
|
|
|
TEST_CASE("SGetCurrentThreadId", "[thread]") {
|
|
SECTION("returns thread id") {
|
|
uintptr_t threadId = SGetCurrentThreadId();
|
|
CHECK(threadId > 0);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("SCritSect::Enter", "[thread]") {
|
|
SECTION("locks critical section") {
|
|
SCritSect critSect;
|
|
critSect.Enter();
|
|
SUCCEED();
|
|
}
|
|
}
|
|
|
|
TEST_CASE("SCritSect::Leave", "[thread]") {
|
|
SECTION("unlocks critical section") {
|
|
SCritSect critSect;
|
|
critSect.Enter();
|
|
critSect.Leave();
|
|
SUCCEED();
|
|
}
|
|
}
|
|
|
|
TEST_CASE("SThread::Create", "[thread]") {
|
|
SECTION("creates new thread") {
|
|
SThread thread;
|
|
auto threadName = const_cast<char*>("TestThread");
|
|
auto threadParam = SMemAlloc(16, nullptr, 0, 0x0);
|
|
REQUIRE(SThread::Create(threadProc, threadParam, thread, threadName, 0) != 0);
|
|
thread.Wait(100);
|
|
}
|
|
}
|