Line data Source code
1 : #include "Utils/SpUtils.hpp" 2 : #include "Legacy/SpRuntime.hpp" 3 : 4 : #include "UTester.hpp" 5 : 6 : class TestInTask : public UTester< TestInTask > { 7 : using Parent = UTester< TestInTask >; 8 : 9 : 10 1 : void TestBasic(){ 11 1 : UASSERTETRUE(SpUtils::GetThreadId() == 0); 12 1 : UASSERTETRUE(SpUtils::IsInTask() == false); 13 : 14 1 : SpRuntime runtime(2); 15 : 16 1 : const int initVal = 1; 17 : 18 0 : runtime.task(SpRead(initVal), 19 1 : [&](const int& /*initValParam*/){ 20 1 : UASSERTETRUE(0 < SpUtils::GetThreadId()); 21 1 : UASSERTETRUE(SpUtils::GetThreadId() <= 2); 22 1 : UASSERTETRUE(SpUtils::IsInTask() == true); 23 5 : }); 24 : 25 0 : runtime.task(SpRead(initVal), 26 1 : [&](const int& /*initValParam*/){ 27 1 : UASSERTETRUE(0 < SpUtils::GetThreadId()); 28 1 : UASSERTETRUE(SpUtils::GetThreadId() <= 2); 29 1 : UASSERTETRUE(SpUtils::IsInTask() == true); 30 2 : }); 31 : 32 0 : runtime.task(SpRead(initVal), 33 1 : [&](const int& /*initValParam*/){ 34 1 : UASSERTETRUE(0 < SpUtils::GetThreadId()); 35 1 : UASSERTETRUE(SpUtils::GetThreadId() <= 2); 36 1 : UASSERTETRUE(SpUtils::IsInTask() == true); 37 2 : }); 38 1 : } 39 : 40 1 : void SetTests() { 41 1 : Parent::AddTest(&TestInTask::TestBasic, "Basic test for utils in task"); 42 1 : } 43 : }; 44 : 45 : // You must do this 46 1 : TestClass(TestInTask) 47 :