mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fix several race conditions
The fixes are specific to unit test environment. PiperOrigin-RevId: 546342096
This commit is contained in:
committed by
Copybara-Service
parent
61820e49fb
commit
ca9bbd3a9c
@@ -125,5 +125,22 @@ TEST(Borrowable, BorrowIsExclusive) {
|
||||
EXPECT_NE(lender.GetBorrowable().Borrow()->GetValue(), kDefaultValue);
|
||||
}
|
||||
|
||||
TEST(Borrowable, DefaultBorrowableFails) {
|
||||
Borrowable<int> borrowable;
|
||||
EXPECT_FALSE(borrowable.Borrow());
|
||||
}
|
||||
|
||||
TEST(Borrowable, CopyBorrowable) {
|
||||
constexpr int kValue = 1;
|
||||
|
||||
Lender<int> lender(kValue);
|
||||
Borrowable<int> borrowable = lender.GetBorrowable();
|
||||
Borrowable<int> copy = borrowable;
|
||||
Borrowed<int> borrowed = copy.Borrow();
|
||||
|
||||
ASSERT_TRUE(borrowed);
|
||||
EXPECT_EQ(*borrowed, kValue);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user