Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 1 | //===-- TimeoutTest.cpp -----------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/Utility/Timeout.h" |
Pavel Labath | d02b1c8 | 2017-02-10 11:49:33 +0000 | [diff] [blame] | 11 | #include "llvm/Support/FormatVariadic.h" |
Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 12 | #include "gtest/gtest.h" |
| 13 | |
| 14 | using namespace lldb_private; |
| 15 | using namespace std::chrono; |
| 16 | |
| 17 | TEST(TimeoutTest, Construction) { |
Pavel Labath | d02b1c8 | 2017-02-10 11:49:33 +0000 | [diff] [blame] | 18 | EXPECT_FALSE(Timeout<std::micro>(llvm::None)); |
| 19 | EXPECT_TRUE(bool(Timeout<std::micro>(seconds(0)))); |
| 20 | EXPECT_EQ(seconds(0), *Timeout<std::micro>(seconds(0))); |
| 21 | EXPECT_EQ(seconds(3), *Timeout<std::micro>(seconds(3))); |
| 22 | EXPECT_TRUE(bool(Timeout<std::micro>(Timeout<std::milli>(seconds(0))))); |
| 23 | } |
| 24 | |
| 25 | TEST(TimeoutTest, Format) { |
| 26 | EXPECT_EQ("<infinite>", |
| 27 | llvm::formatv("{0}", Timeout<std::milli>(llvm::None)).str()); |
| 28 | EXPECT_EQ("1000 ms", |
| 29 | llvm::formatv("{0}", Timeout<std::milli>(seconds(1))).str()); |
Pavel Labath | c4063ee | 2016-11-25 11:58:44 +0000 | [diff] [blame] | 30 | } |