writer_ut.cpp 761 B

1234567891011121314151617181920212223242526272829303132
  1. #include "writer.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. using namespace NMonitoring;
  4. Y_UNIT_TEST_SUITE(JsonWriterTests) {
  5. Y_UNIT_TEST(One) {
  6. TStringStream ss;
  7. TDeprecatedJsonWriter w(&ss);
  8. w.OpenDocument();
  9. w.OpenMetrics();
  10. for (int i = 0; i < 5; ++i) {
  11. w.OpenMetric();
  12. w.OpenLabels();
  13. w.WriteLabel("user", TString("") + (char)('a' + i));
  14. w.WriteLabel("name", "NWrites");
  15. w.CloseLabels();
  16. if (i % 2 == 0) {
  17. w.WriteModeDeriv();
  18. }
  19. w.WriteValue(10l);
  20. w.CloseMetric();
  21. }
  22. w.CloseMetrics();
  23. w.CloseDocument();
  24. //Cout << ss.Str() << "\n";
  25. }
  26. }