MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / testThreadPoolErrors

Method testThreadPoolErrors

Tests/Libraries/Threading/ThreadPoolTest.cpp:85–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85void SC::ThreadPoolTest::testThreadPoolErrors()
86{
87 static const size_t numTasks = 4;
88
89 // Define tasks before threadpool to avoid threadpool destructor accessing invalid tasks
90 SC::ThreadPool::Task tasks[numTasks];
91
92 SC::ThreadPool threadPool;
93 Result result = threadPool.create(0);
94 SC_TEST_EXPECT(result.isError(ThreadingResultCategory, ThreadingError::InvalidWorkerThreadCount));
95
96 SC_TEST_EXPECT(threadPool.create(2));
97 result = threadPool.create(2);
98 SC_TEST_EXPECT(result.isError(ThreadingResultCategory, ThreadingError::ThreadPoolAlreadyCreated));
99
100 SC::ThreadPool threadPool2;
101 SC_TEST_EXPECT(threadPool2.create(1));
102
103 SC::ThreadPool uninitializedThreadPool;
104 result = uninitializedThreadPool.queueTask(tasks[0]);
105 SC_TEST_EXPECT(result.isError(ThreadingResultCategory, ThreadingError::ThreadPoolNotCreated));
106 result = uninitializedThreadPool.waitForTask(tasks[0]);
107 SC_TEST_EXPECT(result.isError(ThreadingResultCategory, ThreadingError::ThreadPoolNotCreated));
108
109 for (size_t idx = 0; idx < numTasks; idx++)
110 {

Callers

nothing calls this directly

Calls 2

queueTaskMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected