fake_ut.cpp 862 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "fake.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. #include <util/generic/ptr.h>
  4. using namespace NMonitoring;
  5. Y_UNIT_TEST_SUITE(TFakeTest) {
  6. Y_UNIT_TEST(CreateOnStack) {
  7. TFakeMetricRegistry registry;
  8. }
  9. Y_UNIT_TEST(CreateOnHeap) {
  10. auto registry = MakeAtomicShared<TFakeMetricRegistry>();
  11. UNIT_ASSERT(registry);
  12. }
  13. Y_UNIT_TEST(Gauge) {
  14. TFakeMetricRegistry registry(TLabels{{"common", "label"}});
  15. IGauge* g = registry.Gauge(MakeLabels({{"my", "gauge"}}));
  16. UNIT_ASSERT(g);
  17. UNIT_ASSERT_DOUBLES_EQUAL(g->Get(), 0.0, 1E-6);
  18. g->Set(12.34);
  19. UNIT_ASSERT_DOUBLES_EQUAL(g->Get(), 0.0, 1E-6); // no changes
  20. double val = g->Add(1.2);
  21. UNIT_ASSERT_DOUBLES_EQUAL(g->Get(), 0.0, 1E-6);
  22. UNIT_ASSERT_DOUBLES_EQUAL(val, 0.0, 1E-6);
  23. }
  24. }