MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / TEST

Function TEST

Engine/source/platform/threads/test/threadTest.cpp:27–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25#include "platform/threads/thread.h"
26
27TEST(Thread, CallbackAPI)
28{
29#define VALUE_TO_SET 10
30
31 // This struct exists just so we can define run as a local function.
32 struct thread
33 {
34 // Do some work we can observe.
35 static void body(void* arg)
36 {
37 U32* value = reinterpret_cast<U32*>(arg);
38 *value = VALUE_TO_SET;
39 }
40 };
41
42 // Test most basic Thread API functions.
43 U32 value = ~VALUE_TO_SET;
44 Thread thread(&thread::body, reinterpret_cast<void*>(&value));
45 thread.start();
46 EXPECT_TRUE(thread.isAlive());
47 thread.join();
48 EXPECT_FALSE(thread.isAlive());
49
50 EXPECT_EQ(value, VALUE_TO_SET)
51 << "Thread did not set expected value!";
52
53#undef VALUE_TO_SET
54}
55
56TEST(Thread, InheritanceAPI)
57{

Callers

nothing calls this directly

Calls 3

startMethod · 0.45
isAliveMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected