| 1 | //===-- TimeoutTest.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/Timeout.h" |
| 10 | #include "llvm/Support/FormatVariadic.h" |
| 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | using namespace lldb_private; |
| 14 | using namespace std::chrono; |
| 15 | |
| 16 | TEST(TimeoutTest, Construction) { |
| 17 | EXPECT_FALSE(Timeout<std::micro>(std::nullopt)); |
| 18 | EXPECT_TRUE(bool(Timeout<std::micro>(seconds(0)))); |
| 19 | EXPECT_EQ(seconds(0), *Timeout<std::micro>(seconds(0))); |
| 20 | EXPECT_EQ(seconds(3), *Timeout<std::micro>(seconds(3))); |
| 21 | EXPECT_TRUE(bool(Timeout<std::micro>(Timeout<std::milli>(seconds(0))))); |
| 22 | } |
| 23 | |
| 24 | TEST(TimeoutTest, Format) { |
| 25 | EXPECT_EQ("<infinite>", |
| 26 | llvm::formatv("{0}", Timeout<std::milli>(std::nullopt)).str()); |
| 27 | EXPECT_EQ("1000 ms", |
| 28 | llvm::formatv("{0}", Timeout<std::milli>(seconds(1))).str()); |
| 29 | } |
| 30 |
