forked from whoahq/squall
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathThread.cpp
58 lines (51 loc) · 1.34 KB
/
Thread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "storm/Thread.hpp"
#include "storm/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);
}
}