aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/util/rope_ut.cpp
diff options
context:
space:
mode:
authoraneporada <aneporada@ydb.tech>2023-06-26 18:23:32 +0300
committeraneporada <aneporada@ydb.tech>2023-06-26 18:23:32 +0300
commit90298d692c83e6f459903ed532b38a0806d626fa (patch)
tree714a7446c8523bb98fa9bb926f39eea700c04691 /library/cpp/actors/util/rope_ut.cpp
parentb9e469eec25bfeaa903be041308020b48098c3ca (diff)
downloadydb-90298d692c83e6f459903ed532b38a0806d626fa.tar.gz
Support IZeroCopyInput over TRope
initial
Diffstat (limited to 'library/cpp/actors/util/rope_ut.cpp')
-rw-r--r--library/cpp/actors/util/rope_ut.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/library/cpp/actors/util/rope_ut.cpp b/library/cpp/actors/util/rope_ut.cpp
index ba7c38044f..0ff85d6c59 100644
--- a/library/cpp/actors/util/rope_ut.cpp
+++ b/library/cpp/actors/util/rope_ut.cpp
@@ -373,4 +373,46 @@ Y_UNIT_TEST_SUITE(TRope) {
}
}
+ Y_UNIT_TEST(RopeZeroCopyInputBasic) {
+ TRope rope = CreateRope(Text, 3);
+ TRopeZeroCopyInput input(rope.Begin());
+
+ TString result;
+ TStringOutput output(result);
+ TransferData(&input, &output);
+ UNIT_ASSERT_EQUAL(result, Text);
+ }
+
+ Y_UNIT_TEST(RopeZeroCopyInput) {
+ TRope rope;
+ rope.Insert(rope.End(), TRope{"abc"});
+ rope.Insert(rope.End(), TRope{TString{}});
+ rope.Insert(rope.End(), TRope{"de"});
+ rope.Insert(rope.End(), TRope{TString{}});
+ rope.Insert(rope.End(), TRope{TString{}});
+ rope.Insert(rope.End(), TRope{"fghi"});
+
+ TRopeZeroCopyInput input(rope.Begin());
+
+ const char* data = nullptr;
+ size_t len;
+
+ len = input.Next(&data, 2);
+ UNIT_ASSERT_EQUAL("ab", TStringBuf(data, len));
+
+ len = input.Next(&data, 3);
+ UNIT_ASSERT_EQUAL("c", TStringBuf(data, len));
+
+ len = input.Next(&data, 3);
+ UNIT_ASSERT_EQUAL("de", TStringBuf(data, len));
+
+ len = input.Next(&data);
+ UNIT_ASSERT_EQUAL("fghi", TStringBuf(data, len));
+
+ len = input.Next(&data);
+ UNIT_ASSERT_EQUAL(len, 0);
+
+ len = input.Next(&data);
+ UNIT_ASSERT_EQUAL(len, 0);
+ }
}