brintos

brintos / llvm-project-archived public Read only

0
0
Text · 992 B · 2576049 Raw
32 lines · cpp
1//===- unittests/ExponentialBackoffTest.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 "llvm/Support/ExponentialBackoff.h"10#include "gtest/gtest.h"11#include <chrono>12 13using namespace llvm;14using namespace std::chrono_literals;15 16namespace {17 18TEST(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);22  do {23  } while (Backoff.waitForNextAttempt());24  auto Duration = std::chrono::steady_clock::now() - Start;25  EXPECT_GE(Duration, 100ms);26}27 28// Testing individual wait duration is omitted as those tests would be29// non-deterministic.30 31} // end anonymous namespace32