1 //===- unittests/ExponentialBackoffTest.cpp -------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/ExponentialBackoff.h"
10 #include "gtest/gtest.h"
14 using namespace std::chrono_literals
;
18 TEST(ExponentialBackoffTest
, Timeout
) {
19 auto Start
= std::chrono::steady_clock::now();
20 // Use short enough times that this test runs quickly.
21 ExponentialBackoff
Backoff(100ms
, 1ms
, 10ms
);
23 } while (Backoff
.waitForNextAttempt());
24 auto Duration
= std::chrono::steady_clock::now() - Start
;
25 EXPECT_GE(Duration
, 100ms
);
28 // Testing individual wait duration is omitted as those tests would be
31 } // end anonymous namespace