ztstrbuf_ut.cpp 793 B

12345678910111213141516171819202122232425262728
  1. #include "ztstrbuf.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. Y_UNIT_TEST_SUITE(TZtStringBufTest) {
  4. Y_UNIT_TEST(EmptyString) {
  5. TZtStringBuf s0{};
  6. UNIT_ASSERT_VALUES_EQUAL(s0, TString{""});
  7. UNIT_ASSERT_VALUES_EQUAL(s0.c_str(), TString{""});
  8. }
  9. Y_UNIT_TEST(Constness) {
  10. constexpr TZtStringBuf s0{"bar"};
  11. static_assert(s0[0] == 'b');
  12. static_assert(s0[3] == '\0');
  13. static_assert(s0.data()[2] == 'r');
  14. UNIT_ASSERT_VALUES_EQUAL(s0, TString{"bar"});
  15. }
  16. Y_UNIT_TEST(FromString) {
  17. TString str0{"foo"};
  18. TZtStringBuf s0 = str0;
  19. UNIT_ASSERT_VALUES_EQUAL(s0, "foo");
  20. std::string str1{"bar"};
  21. TZtStringBuf s1 = str1;
  22. UNIT_ASSERT_VALUES_EQUAL(s1, "bar");
  23. }
  24. }