Improving test coverage [adding Mutex::LockUnlock]

Signed-off-by: Stefano Fiorentino <stefano.fiore84@gmail.com>
This commit is contained in:
Stefano Fiorentino 2020-03-27 11:53:25 +01:00
parent 53da326aea
commit bfc4a2c95b

View File

@ -25,4 +25,20 @@ TEST(ThreadLocalStorage, SetGet) {
localStorage->set<bool>(&flag); localStorage->set<bool>(&flag);
ASSERT_TRUE(localStorage->get<bool>()); ASSERT_TRUE(localStorage->get<bool>());
loop->run();
}
TEST(Mutex, LockUnlock) {
auto loop = uvw::Loop::getDefault();
auto mtx = loop->resource<uvw::Mutex>();
mtx->lock();
ASSERT_FALSE(mtx->tryLock());
mtx->unlock();
ASSERT_TRUE(mtx->tryLock());
ASSERT_FALSE(mtx->tryLock());
mtx->unlock();
loop->run();
} }