Skip to content

Commit

Permalink
[tests] Added CThread::joinable() unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Oct 26, 2020
1 parent 929b9fc commit 8903060
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_sync.cpp
Expand Up @@ -512,6 +512,34 @@ TEST(SyncEvent, WaitForNotifyAll)
cond.destroy();
}

/*****************************************************************************/
/*
* CThread
*/
/*****************************************************************************/
void* dummythread(void* param)
{
*(bool*)(param) = true;
return nullptr;
}

TEST(SyncThread, Joinable)
{
CThread foo;
volatile bool thread_finished = false;

StartThread(foo, dummythread, (void*)&thread_finished, "DumyThread");

EXPECT_TRUE(foo.joinable());
while (!thread_finished)
{
std::this_thread::sleep_for(chrono::milliseconds(50));
}
EXPECT_TRUE(foo.joinable());
foo.join();
EXPECT_FALSE(foo.joinable());
}

/*****************************************************************************/
/*
* FormatTime
Expand Down

0 comments on commit 8903060

Please sign in to comment.