diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 | 
| commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
| tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /unittests/Utility/PredicateTest.cpp | |
| parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) | |
Notes
Diffstat (limited to 'unittests/Utility/PredicateTest.cpp')
| -rw-r--r-- | unittests/Utility/PredicateTest.cpp | 34 | 
1 files changed, 34 insertions, 0 deletions
diff --git a/unittests/Utility/PredicateTest.cpp b/unittests/Utility/PredicateTest.cpp new file mode 100644 index 000000000000..327dd80b23ee --- /dev/null +++ b/unittests/Utility/PredicateTest.cpp @@ -0,0 +1,34 @@ +//===-- PredicateTest.cpp ---------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/Predicate.h" +#include "gtest/gtest.h" +#include <thread> + +using namespace lldb_private; + +TEST(Predicate, WaitForValueEqualTo) { +  Predicate<int> P(0); +  EXPECT_TRUE(P.WaitForValueEqualTo(0)); +  EXPECT_FALSE(P.WaitForValueEqualTo(1, std::chrono::milliseconds(10))); + +  std::thread Setter([&P] { +    std::this_thread::sleep_for(std::chrono::milliseconds(100)); +    P.SetValue(1, eBroadcastAlways); +  }); +  EXPECT_TRUE(P.WaitForValueEqualTo(1)); +  Setter.join(); +} + +TEST(Predicate, WaitForValueNotEqualTo) { +  Predicate<int> P(0); +  EXPECT_EQ(0, P.WaitForValueNotEqualTo(1)); +  EXPECT_EQ(llvm::None, +            P.WaitForValueNotEqualTo(0, std::chrono::milliseconds(10))); +}  | 
