1 //===-- PredicateTest.cpp -------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Utility/Predicate.h"
10 #include "gtest/gtest.h"
13 using namespace lldb_private
;
15 TEST(Predicate
, WaitForValueEqualTo
) {
17 EXPECT_TRUE(P
.WaitForValueEqualTo(0));
18 EXPECT_FALSE(P
.WaitForValueEqualTo(1, std::chrono::milliseconds(10)));
20 std::thread
Setter([&P
] {
21 std::this_thread::sleep_for(std::chrono::milliseconds(100));
22 P
.SetValue(1, eBroadcastAlways
);
24 EXPECT_TRUE(P
.WaitForValueEqualTo(1));
28 TEST(Predicate
, WaitForValueNotEqualTo
) {
30 EXPECT_EQ(0, P
.WaitForValueNotEqualTo(1));
31 EXPECT_EQ(std::nullopt
,
32 P
.WaitForValueNotEqualTo(0, std::chrono::milliseconds(10)));