aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/buffered_ut.cpp
diff options
context:
space:
mode:
authornikitamorozov <nikitamorozov@yandex-team.ru>2022-02-10 16:49:20 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:20 +0300
commit2342f2b56e674c21307fcb92a37853f950224d31 (patch)
tree7e3170fde6aea33759fe624ee5b7ec29de8af150 /util/stream/buffered_ut.cpp
parent2896882074ce784b7cabc4f2f7c502db74b34b80 (diff)
downloadydb-2342f2b56e674c21307fcb92a37853f950224d31.tar.gz
Restoring authorship annotation for <nikitamorozov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/stream/buffered_ut.cpp')
-rw-r--r--util/stream/buffered_ut.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/util/stream/buffered_ut.cpp b/util/stream/buffered_ut.cpp
index 41d2fc30308..451f31dbc65 100644
--- a/util/stream/buffered_ut.cpp
+++ b/util/stream/buffered_ut.cpp
@@ -73,40 +73,40 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(s, "123");
}
- template <class TOut>
+ template <class TOut>
inline void DoGenAndWrite(TOut&& output, TString& str) {
- TMersenne<ui64> r;
- for (size_t i = 0; i < 43210; ++i) {
- str.append('A' + (r.GenRand() % 10));
- }
- size_t written = 0;
- void* ptr = nullptr;
- while (written < str.size()) {
- size_t bufferSize = output.Next(&ptr);
- UNIT_ASSERT(ptr && bufferSize > 0);
- size_t toWrite = Min(bufferSize, str.size() - written);
- memcpy(ptr, str.begin() + written, toWrite);
- written += toWrite;
- if (toWrite < bufferSize) {
- output.Undo(bufferSize - toWrite);
- }
- }
- }
-
- Y_UNIT_TEST(TestWriteViaNextAndUndo) {
- TString str1, str2;
- DoGenAndWrite(TBuffered<TStringOutput>(5000, str1), str2);
-
- UNIT_ASSERT_STRINGS_EQUAL(str1, str2);
- }
-
- Y_UNIT_TEST(TestWriteViaNextAndUndoAdaptive) {
- TString str1, str2;
- DoGenAndWrite(TAdaptivelyBuffered<TStringOutput>(str1), str2);
-
- UNIT_ASSERT_STRINGS_EQUAL(str1, str2);
- }
-
+ TMersenne<ui64> r;
+ for (size_t i = 0; i < 43210; ++i) {
+ str.append('A' + (r.GenRand() % 10));
+ }
+ size_t written = 0;
+ void* ptr = nullptr;
+ while (written < str.size()) {
+ size_t bufferSize = output.Next(&ptr);
+ UNIT_ASSERT(ptr && bufferSize > 0);
+ size_t toWrite = Min(bufferSize, str.size() - written);
+ memcpy(ptr, str.begin() + written, toWrite);
+ written += toWrite;
+ if (toWrite < bufferSize) {
+ output.Undo(bufferSize - toWrite);
+ }
+ }
+ }
+
+ Y_UNIT_TEST(TestWriteViaNextAndUndo) {
+ TString str1, str2;
+ DoGenAndWrite(TBuffered<TStringOutput>(5000, str1), str2);
+
+ UNIT_ASSERT_STRINGS_EQUAL(str1, str2);
+ }
+
+ Y_UNIT_TEST(TestWriteViaNextAndUndoAdaptive) {
+ TString str1, str2;
+ DoGenAndWrite(TAdaptivelyBuffered<TStringOutput>(str1), str2);
+
+ UNIT_ASSERT_STRINGS_EQUAL(str1, str2);
+ }
+
Y_UNIT_TEST(TestInput) {
TString s("0123456789abcdefghijklmn");
TBuffered<TStringInput> in(5, s);