From 08454dfa5385333cec57d26ee7fe483be01f2285 Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Tue, 2 Jul 2019 11:32:58 +0000 Subject: [PATCH] new: test token bucket declaration triggers the default init Co-Authored-By: Lorenzo Fontana Signed-off-by: Leonardo Di Donato --- tests/engine/test_token_bucket.cpp | 8 +++++++- userspace/engine/token_bucket.h | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/engine/test_token_bucket.cpp b/tests/engine/test_token_bucket.cpp index 412c996b..01893027 100644 --- a/tests/engine/test_token_bucket.cpp +++ b/tests/engine/test_token_bucket.cpp @@ -74,4 +74,10 @@ TEST_CASE("token bucket with 2 tokens/sec rate, max 10 tokens", "[token_bucket]" } } } -} \ No newline at end of file +} + +TEST_CASE("token bucket default initialization", "[token_bucket]") +{ + token_bucket tb; + REQUIRE(tb.get_tokens() == 1); +} diff --git a/userspace/engine/token_bucket.h b/userspace/engine/token_bucket.h index 03c4790e..1dd60c26 100644 --- a/userspace/engine/token_bucket.h +++ b/userspace/engine/token_bucket.h @@ -22,8 +22,6 @@ limitations under the License. #include #include -using token_timer = std::function; - // A simple token bucket that accumulates tokens at a fixed rate and allows // for limited bursting in the form of "banked" tokens. class token_bucket @@ -79,4 +77,4 @@ class token_bucket // Nanoseconds since the epoch. // uint64_t m_last_seen; -}; \ No newline at end of file +};