summaryrefslogtreecommitdiffstats
path: root/util/stream/buffered_ut.cpp
diff options
context:
space:
mode:
authornikitamorozov <[email protected]>2022-02-10 16:49:20 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:49:20 +0300
commit523d26598d9784601932189f7fceb34d61bf7641 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/stream/buffered_ut.cpp
parent2342f2b56e674c21307fcb92a37853f950224d31 (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 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 451f31dbc65..41d2fc30308 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);