Raphael Isemann | 8081428 | 2020-01-24 08:23:27 +0100 | [diff] [blame] | 1 | //===-- TimeoutTest.cpp ---------------------------------------------------===// |
Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "lldb/Utility/Timeout.h" |
Pavel Labath | d02b1c8 | 2017-02-10 11:49:33 +0000 | [diff] [blame] | 10 | #include "llvm/Support/FormatVariadic.h" |
Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | using namespace lldb_private; |
| 14 | using namespace std::chrono; |
| 15 | |
| 16 | TEST(TimeoutTest, Construction) { |
Pavel Labath | d02b1c8 | 2017-02-10 11:49:33 +0000 | [diff] [blame] | 17 | EXPECT_FALSE(Timeout<std::micro>(llvm::None)); |
| 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>(llvm::None)).str()); |
| 27 | EXPECT_EQ("1000 ms", |
| 28 | llvm::formatv("{0}", Timeout<std::milli>(seconds(1))).str()); |
Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 29 | } |