diff options
author | 2020-08-03 14:33:06 +0000 | |
---|---|---|
committer | 2020-08-03 14:33:06 +0000 | |
commit | 061da546b983eb767bad15e67af1174fb0bcf31c (patch) | |
tree | 83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/unittests/Utility/PredicateTest.cpp | |
parent | Import LLVM 10.0.0 release including clang, lld and lldb. (diff) | |
download | wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip |
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom
tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/unittests/Utility/PredicateTest.cpp')
-rw-r--r-- | gnu/llvm/lldb/unittests/Utility/PredicateTest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/unittests/Utility/PredicateTest.cpp b/gnu/llvm/lldb/unittests/Utility/PredicateTest.cpp new file mode 100644 index 00000000000..45b20c601d6 --- /dev/null +++ b/gnu/llvm/lldb/unittests/Utility/PredicateTest.cpp @@ -0,0 +1,33 @@ +//===-- PredicateTest.cpp ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#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))); +} |