rty_formater_ut.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #include "rty_formater.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. namespace {
  4. const TStringBuf SampleISO8601("2017-07-25T19:26:09.894000+03:00");
  5. const TStringBuf SampleRtyLog("2017-07-25 19:26:09.894 +0300");
  6. }
  7. Y_UNIT_TEST_SUITE(NLoggingImplTest) {
  8. Y_UNIT_TEST(TestTLocalTimeSToStream) {
  9. NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
  10. TStringStream ss;
  11. ss << lt;
  12. UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog);
  13. }
  14. Y_UNIT_TEST(TestTLocalTimeSToString) {
  15. NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
  16. UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog);
  17. }
  18. Y_UNIT_TEST(TestTLocalTimeSAddLeft) {
  19. NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
  20. TStringBuf suffix("suffix");
  21. UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix);
  22. }
  23. Y_UNIT_TEST(TestTLocalTimeSAddRight) {
  24. NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
  25. TString prefix("prefix");
  26. UNIT_ASSERT_EQUAL(prefix + lt, prefix + SampleRtyLog);
  27. }
  28. }