summaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/util/rc_buf_ut.cpp
diff options
context:
space:
mode:
authorinnokentii <[email protected]>2022-12-13 15:22:28 +0300
committerinnokentii <[email protected]>2022-12-13 15:22:28 +0300
commit1ab9ee3dfe0ab4023a3a57bf55de31dff3eac908 (patch)
tree49281129fa2e474ed2ceae61823b5737e69a17b2 /library/cpp/actors/util/rc_buf_ut.cpp
parent3e76f9f3fefc86eb2f0151ce8ad18d0816ce3522 (diff)
Add TStringBuf conversion operator for TRcBuf
add TStringBuf conversion operator add TStringBuf conversion operator
Diffstat (limited to 'library/cpp/actors/util/rc_buf_ut.cpp')
-rw-r--r--library/cpp/actors/util/rc_buf_ut.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/library/cpp/actors/util/rc_buf_ut.cpp b/library/cpp/actors/util/rc_buf_ut.cpp
index 9b8af6421da..c23e8b68d09 100644
--- a/library/cpp/actors/util/rc_buf_ut.cpp
+++ b/library/cpp/actors/util/rc_buf_ut.cpp
@@ -10,6 +10,16 @@ Y_UNIT_TEST_SUITE(TRcBuf) {
UNIT_ASSERT_EQUAL(sizeof(TRcBuf), 4 * sizeof(uintptr_t));
}
+ Y_UNIT_TEST(Slice) {
+ auto data = TRcBuf::Copy("Hello", 5);
+ UNIT_ASSERT_VALUES_EQUAL(TString(TStringBuf(data)), TString("Hello"));
+ UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice()), TString("Hello"));
+ UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice(1)), TString("ello"));
+ UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice(1, 3)), TString("ell"));
+ UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice(1, 100)), TString("ello"));
+ UNIT_ASSERT_VALUES_EQUAL(TString(data.Slice(0, 4)), TString("Hell"));
+ }
+
Y_UNIT_TEST(CrossCompare) {
TString str = "some very long string";
const TString constStr(str);
@@ -159,7 +169,7 @@ Y_UNIT_TEST_SUITE(TRcBuf) {
Y_UNIT_TEST(SliceUnshare) {
TRcBuf data = TRcBuf::Uninitialized(10, 20, 30);
- TRcBuf otherData(TRcBuf::Slice, data.data() + 1, data.size() - 2, data);
+ TRcBuf otherData(TRcBuf::Piece, data.data() + 1, data.size() - 2, data);
UNIT_ASSERT_EQUAL(otherData.Headroom(), 0);
UNIT_ASSERT_EQUAL(otherData.Tailroom(), 0);
}