summaryrefslogtreecommitdiffstats
path: root/util/string/cast_ut.cpp
diff options
context:
space:
mode:
authorosidorkin <[email protected]>2023-03-23 12:15:57 +0300
committerosidorkin <[email protected]>2023-03-23 12:15:57 +0300
commit8cfa97b5487686f556b3dae62132c8f099b1a0b3 (patch)
treebdf7d7ab18e12b5a22db8341f0231eaea484ded4 /util/string/cast_ut.cpp
parent8d5942b8f813c0e704a166c3c83902ccceefca07 (diff)
util: Add constexpr int to string conversion class. This will allow us not to have heap allocations when joining ints to string
Diffstat (limited to 'util/string/cast_ut.cpp')
-rw-r--r--util/string/cast_ut.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 8690fa78dca..0ff92e379bd 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -587,4 +587,16 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(U'я'), "1103");
UNIT_ASSERT_VALUES_EQUAL(ToString(U'\U0001F600'), "128512"); // 'GRINNING FACE' (U+1F600)
}
+
+ Y_UNIT_TEST(TestTIntStringBuf) {
+ static_assert(TStringBuf(TIntStringBuf(111)) == TStringBuf("111"));
+ static_assert(TStringBuf(TIntStringBuf(-111)) == TStringBuf("-111"));
+ UNIT_ASSERT_VALUES_EQUAL(TStringBuf(TIntStringBuf(0)), "0"sv);
+ UNIT_ASSERT_VALUES_EQUAL(TStringBuf(TIntStringBuf(1111)), "1111"sv);
+ UNIT_ASSERT_VALUES_EQUAL(TStringBuf(TIntStringBuf(-1)), "-1"sv);
+ UNIT_ASSERT_VALUES_EQUAL(TStringBuf(TIntStringBuf(-1111)), "-1111"sv);
+
+ constexpr auto v = TIntStringBuf(-1111);
+ UNIT_ASSERT_VALUES_EQUAL(TStringBuf(v), TStringBuf(ToString(-1111)));
+ }
};