#include "fake.h" #include #include using namespace NMonitoring; Y_UNIT_TEST_SUITE(TFakeTest) { Y_UNIT_TEST(CreateOnStack) { TFakeMetricRegistry registry; } Y_UNIT_TEST(CreateOnHeap) { auto registry = MakeAtomicShared(); UNIT_ASSERT(registry); } Y_UNIT_TEST(Gauge) { TFakeMetricRegistry registry(TLabels{{"common", "label"}}); IGauge* g = registry.Gauge(MakeLabels({{"my", "gauge"}})); UNIT_ASSERT(g); UNIT_ASSERT_DOUBLES_EQUAL(g->Get(), 0.0, 1E-6); g->Set(12.34); UNIT_ASSERT_DOUBLES_EQUAL(g->Get(), 0.0, 1E-6); // no changes double val = g->Add(1.2); UNIT_ASSERT_DOUBLES_EQUAL(g->Get(), 0.0, 1E-6); UNIT_ASSERT_DOUBLES_EQUAL(val, 0.0, 1E-6); } }