llvm-project
33 строки · 1.0 Кб
1//===-- PredicateTest.cpp -------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Utility/Predicate.h"10#include "gtest/gtest.h"11#include <thread>12
13using namespace lldb_private;14
15TEST(Predicate, WaitForValueEqualTo) {16Predicate<int> P(0);17EXPECT_TRUE(P.WaitForValueEqualTo(0));18EXPECT_FALSE(P.WaitForValueEqualTo(1, std::chrono::milliseconds(10)));19
20std::thread Setter([&P] {21std::this_thread::sleep_for(std::chrono::milliseconds(100));22P.SetValue(1, eBroadcastAlways);23});24EXPECT_TRUE(P.WaitForValueEqualTo(1));25Setter.join();26}
27
28TEST(Predicate, WaitForValueNotEqualTo) {29Predicate<int> P(0);30EXPECT_EQ(0, P.WaitForValueNotEqualTo(1));31EXPECT_EQ(std::nullopt,32P.WaitForValueNotEqualTo(0, std::chrono::milliseconds(10)));33}
34