aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/io/chunk_ut.cpp
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commit863a59a65247c24db7cb06789bc5cf79d04da32f (patch)
tree139dc000c8cd4a40f5659e421b7c75135d080307 /library/cpp/http/io/chunk_ut.cpp
parentf64e95a9eb9ab03240599eb9581c5a9102426a96 (diff)
downloadydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/io/chunk_ut.cpp')
-rw-r--r--library/cpp/http/io/chunk_ut.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp
index da283f8568..beaeababd2 100644
--- a/library/cpp/http/io/chunk_ut.cpp
+++ b/library/cpp/http/io/chunk_ut.cpp
@@ -13,50 +13,50 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
TString CombString(const TString& s, size_t chunkSize) {
TString result;
- for (size_t pos = 0; pos < s.size(); pos += 2 * chunkSize)
- result += s.substr(pos, chunkSize);
- return result;
- }
-
+ for (size_t pos = 0; pos < s.size(); pos += 2 * chunkSize)
+ result += s.substr(pos, chunkSize);
+ return result;
+ }
+
void WriteTestData(IOutputStream * stream, TString * contents) {
- contents->clear();
- for (size_t i = 0; i < sizeof(test_data); ++i) {
- stream->Write(test_data, i);
- contents->append(test_data, i);
- }
- }
-
+ contents->clear();
+ for (size_t i = 0; i < sizeof(test_data); ++i) {
+ stream->Write(test_data, i);
+ contents->append(test_data, i);
+ }
+ }
+
void ReadInSmallChunks(IInputStream * stream, TString * contents) {
- char buf[11];
- size_t read = 0;
-
- contents->clear();
- do {
- read = stream->Read(buf, sizeof(buf));
- contents->append(buf, read);
- } while (read > 0);
- }
-
+ char buf[11];
+ size_t read = 0;
+
+ contents->clear();
+ do {
+ read = stream->Read(buf, sizeof(buf));
+ contents->append(buf, read);
+ } while (read > 0);
+ }
+
void ReadCombed(IInputStream * stream, TString * contents, size_t chunkSize) {
Y_ASSERT(chunkSize < 128);
- char buf[128];
-
- contents->clear();
- while (true) {
- size_t read = stream->Load(buf, chunkSize);
- contents->append(buf, read);
- if (read == 0)
- break;
-
- size_t toSkip = chunkSize;
- size_t skipped = 0;
- do {
- skipped = stream->Skip(toSkip);
- toSkip -= skipped;
- } while (skipped != 0 && toSkip != 0);
- }
- }
-
+ char buf[128];
+
+ contents->clear();
+ while (true) {
+ size_t read = stream->Load(buf, chunkSize);
+ contents->append(buf, read);
+ if (read == 0)
+ break;
+
+ size_t toSkip = chunkSize;
+ size_t skipped = 0;
+ do {
+ skipped = stream->Skip(toSkip);
+ toSkip -= skipped;
+ } while (skipped != 0 && toSkip != 0);
+ }
+ }
+
Y_UNIT_TEST(TestChunkedIo) {
TTempFile tmpFile(CDATA);
TString tmp;
@@ -64,17 +64,17 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
{
TUnbufferedFileOutput fo(CDATA);
TChunkedOutput co(&fo);
- WriteTestData(&co, &tmp);
- }
+ WriteTestData(&co, &tmp);
+ }
- {
+ {
TUnbufferedFileInput fi(CDATA);
- TChunkedInput ci(&fi);
+ TChunkedInput ci(&fi);
TString r;
- ReadInSmallChunks(&ci, &r);
-
- UNIT_ASSERT_EQUAL(r, tmp);
+ ReadInSmallChunks(&ci, &r);
+
+ UNIT_ASSERT_EQUAL(r, tmp);
}
{
@@ -82,9 +82,9 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
TChunkedInput ci(&fi);
TString r;
- ReadCombed(&ci, &r, 11);
+ ReadCombed(&ci, &r, 11);
- UNIT_ASSERT_EQUAL(r, CombString(tmp, 11));
+ UNIT_ASSERT_EQUAL(r, CombString(tmp, 11));
}
}