aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/ztstrbuf/ztstrbuf_ut.cpp
blob: b22d4bf216d514bf41650d53d04ffdbafb601f10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "ztstrbuf.h"

#include <library/cpp/testing/unittest/registar.h>

Y_UNIT_TEST_SUITE(TZtStringBufTest) {
    Y_UNIT_TEST(EmptyString) {
        TZtStringBuf s0{};
        UNIT_ASSERT_VALUES_EQUAL(s0, TString{""});
        UNIT_ASSERT_VALUES_EQUAL(s0.c_str(), TString{""});
    }

    Y_UNIT_TEST(Constness) {
        constexpr TZtStringBuf s0{"bar"};
        static_assert(s0[0] == 'b');
        static_assert(s0.data()[s0.size()] == '\0');
        static_assert(s0.data()[2] == 'r');
        UNIT_ASSERT_VALUES_EQUAL(s0, TString{"bar"});
    }

    Y_UNIT_TEST(FromString) {
        TString str0{"foo"};
        TZtStringBuf s0 = str0;
        UNIT_ASSERT_VALUES_EQUAL(s0, "foo");
        std::string str1{"bar"};
        TZtStringBuf s1 = str1;
        UNIT_ASSERT_VALUES_EQUAL(s1, "bar");
    }
}