From b72f81540b1852df4c50e26e9ba1798897a59da5 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Thu, 17 Feb 2022 09:07:46 -0800 Subject: [PATCH] Create IXExponentialBackoffTest.cpp --- test/IXExponentialBackoffTest.cpp | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/IXExponentialBackoffTest.cpp diff --git a/test/IXExponentialBackoffTest.cpp b/test/IXExponentialBackoffTest.cpp new file mode 100644 index 00000000..74d15c72 --- /dev/null +++ b/test/IXExponentialBackoffTest.cpp @@ -0,0 +1,36 @@ +/* + * IXExponentialBackoffTest.cpp + * Author: Benjamin Sergeant + * Copyright (c) 2022 Machine Zone. All rights reserved. + */ + +#include "IXTest.h" +#include "catch.hpp" +#include +#include +#include + +using namespace ix; + +namespace ix +{ + TEST_CASE("exponential_backoff", "[exponential_backoff]") + { + SECTION("1") + { + // First parameter is retrycount + REQUIRE(calculateRetryWaitMilliseconds(0, 10000, 100) == 100); + REQUIRE(calculateRetryWaitMilliseconds(1, 10000, 100) == 200); + REQUIRE(calculateRetryWaitMilliseconds(2, 10000, 100) == 400); + REQUIRE(calculateRetryWaitMilliseconds(3, 10000, 100) == 800); + REQUIRE(calculateRetryWaitMilliseconds(4, 10000, 100) == 1600); + REQUIRE(calculateRetryWaitMilliseconds(5, 10000, 100) == 3200); + REQUIRE(calculateRetryWaitMilliseconds(6, 10000, 100) == 6400); + REQUIRE(calculateRetryWaitMilliseconds(20, 10000, 100) == 10000); + REQUIRE(calculateRetryWaitMilliseconds(25, 10000, 100) == 10000); + + // FIXME bug when retrycount > 25 + } + } + +} // namespace ix