30 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Utility/Timeout.h"10#include "llvm/Support/FormatVariadic.h"11#include "gtest/gtest.h"12 13using namespace lldb_private;14using namespace std::chrono;15 16TEST(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 24TEST(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