[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Utility / TimeoutTest.cpp
blob028b8cb08315470c57cfccca72ca085257691e07
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 //===----------------------------------------------------------------------===//
9 #include "lldb/Utility/Timeout.h"
10 #include "llvm/Support/FormatVariadic.h"
11 #include "gtest/gtest.h"
13 using namespace lldb_private;
14 using namespace std::chrono;
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)))));
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());