blob: 222ee5db1774287e50747b6219af43c662946b92 [file] [log] [blame]
Raphael Isemann80814282020-01-24 08:23:27 +01001//===-- TimeoutTest.cpp ---------------------------------------------------===//
Pavel Labathc4063ee2016-11-25 11:58:44 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Labathc4063ee2016-11-25 11:58:44 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Utility/Timeout.h"
Pavel Labathd02b1c82017-02-10 11:49:33 +000010#include "llvm/Support/FormatVariadic.h"
Pavel Labathc4063ee2016-11-25 11:58:44 +000011#include "gtest/gtest.h"
12
13using namespace lldb_private;
14using namespace std::chrono;
15
16TEST(TimeoutTest, Construction) {
Pavel Labathd02b1c82017-02-10 11:49:33 +000017 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
24TEST(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 Labathc4063ee2016-11-25 11:58:44 +000029}