fixing test coverage

This commit is contained in:
matlabbe
2026-09-27 18:18:17 -07:00
parent 8b1994cc4f
commit 90e5a21b36
+15
View File
@@ -202,6 +202,21 @@ TEST(UMutexTest, UScopeMutexDeferredLock)
t.join();
}
TEST(UMutexTest, UScopeMutexLockWhenHeld)
{
UMutex mutex;
{
UScopeMutex scopeMutex(mutex); // locked by the constructor
EXPECT_EQ(scopeMutex.lock(), 0); // Already held: not locked a second time
EXPECT_TRUE(scopeMutex.isLocked());
}
std::thread t([&mutex]() {
EXPECT_EQ(mutex.lockTry(), 0); // Unlocked once by the destructor, and free
mutex.unlock();
});
t.join();
}
TEST(UMutexTest, UScopeMutexLockTrySucceeds)
{
UMutex mutex;