Commit 0db5680e authored by Dominik Charousset's avatar Dominik Charousset

Combine gauge unit tests into a single file

parent e1557797
...@@ -309,9 +309,8 @@ caf_add_test_suites(caf-core-test ...@@ -309,9 +309,8 @@ caf_add_test_suites(caf-core-test
string_view string_view
sum_type sum_type
telemetry.collector.prometheus telemetry.collector.prometheus
telemetry.dbl_gauge telemetry.gauge
telemetry.histogram telemetry.histogram
telemetry.int_gauge
telemetry.label telemetry.label
telemetry.metric_registry telemetry.metric_registry
thread_hook thread_hook
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#define CAF_SUITE telemetry.dbl_gauge #define CAF_SUITE telemetry.gauge
#include "caf/telemetry/dbl_gauge.hpp" #include "caf/telemetry/gauge.hpp"
#include "caf/test/dsl.hpp" #include "caf/test/dsl.hpp"
...@@ -42,3 +42,22 @@ CAF_TEST(double gauges can increment and decrement) { ...@@ -42,3 +42,22 @@ CAF_TEST(double gauges can increment and decrement) {
CAF_MESSAGE("users can create gauges with custom start values"); CAF_MESSAGE("users can create gauges with custom start values");
CAF_CHECK_EQUAL(telemetry::dbl_gauge{42.0}.value(), 42.0); CAF_CHECK_EQUAL(telemetry::dbl_gauge{42.0}.value(), 42.0);
} }
CAF_TEST(integer gauges can increment and decrement) {
telemetry::int_gauge g;
CAF_MESSAGE("gauges start at 0");
CAF_CHECK_EQUAL(g.value(), 0);
CAF_MESSAGE("gauges are incrementable");
g.inc();
g.inc(2);
CAF_CHECK_EQUAL(g.value(), 3);
CAF_MESSAGE("gauges are decrementable");
g.dec();
g.dec(5);
CAF_CHECK_EQUAL(g.value(), -3);
CAF_MESSAGE("gauges allow setting values");
g.value(42);
CAF_CHECK_EQUAL(g.value(), 42);
CAF_MESSAGE("users can create gauges with custom start values");
CAF_CHECK_EQUAL(telemetry::int_gauge{42}.value(), 42);
}
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2020 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#define CAF_SUITE telemetry.int_gauge
#include "caf/telemetry/int_gauge.hpp"
#include "caf/test/dsl.hpp"
using namespace caf;
CAF_TEST(integer gauges can increment and decrement) {
telemetry::int_gauge g;
CAF_MESSAGE("gauges start at 0");
CAF_CHECK_EQUAL(g.value(), 0);
CAF_MESSAGE("gauges are incrementable");
g.inc();
g.inc(2);
CAF_CHECK_EQUAL(g.value(), 3);
CAF_MESSAGE("gauges are decrementable");
g.dec();
g.dec(5);
CAF_CHECK_EQUAL(g.value(), -3);
CAF_MESSAGE("gauges allow setting values");
g.value(42);
CAF_CHECK_EQUAL(g.value(), 42);
CAF_MESSAGE("users can create gauges with custom start values");
CAF_CHECK_EQUAL(telemetry::int_gauge{42}.value(), 42);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment