diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/http/io/chunk_ut.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/io/chunk_ut.cpp')
-rw-r--r-- | library/cpp/http/io/chunk_ut.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp index 82f9c90b74..da283f8568 100644 --- a/library/cpp/http/io/chunk_ut.cpp +++ b/library/cpp/http/io/chunk_ut.cpp @@ -1,16 +1,16 @@ -#include "chunk.h" - +#include "chunk.h" + #include <library/cpp/testing/unittest/registar.h> - + #include <util/stream/file.h> -#include <util/system/tempfile.h> +#include <util/system/tempfile.h> #include <util/stream/null.h> - -#define CDATA "./chunkedio" - + +#define CDATA "./chunkedio" + Y_UNIT_TEST_SUITE(TestChunkedIO) { - static const char test_data[] = "87s6cfbsudg cuisg s igasidftasiy tfrcua6s"; - + static const char test_data[] = "87s6cfbsudg cuisg s igasidftasiy tfrcua6s"; + TString CombString(const TString& s, size_t chunkSize) { TString result; for (size_t pos = 0; pos < s.size(); pos += 2 * chunkSize) @@ -58,48 +58,48 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } Y_UNIT_TEST(TestChunkedIo) { - TTempFile tmpFile(CDATA); + TTempFile tmpFile(CDATA); TString tmp; - - { + + { TUnbufferedFileOutput fo(CDATA); - TChunkedOutput co(&fo); + TChunkedOutput co(&fo); WriteTestData(&co, &tmp); } - + { TUnbufferedFileInput fi(CDATA); TChunkedInput ci(&fi); TString r; - + ReadInSmallChunks(&ci, &r); UNIT_ASSERT_EQUAL(r, tmp); - } - - { + } + + { TUnbufferedFileInput fi(CDATA); - TChunkedInput ci(&fi); + TChunkedInput ci(&fi); TString r; - + ReadCombed(&ci, &r, 11); - + UNIT_ASSERT_EQUAL(r, CombString(tmp, 11)); - } - } - + } + } + Y_UNIT_TEST(TestBadChunk) { - bool hasError = false; - - try { + bool hasError = false; + + try { TString badChunk = "10\r\nqwerty"; TMemoryInput mi(badChunk.data(), badChunk.size()); - TChunkedInput ci(&mi); - TransferData(&ci, &Cnull); - } catch (...) { - hasError = true; - } - - UNIT_ASSERT(hasError); - } -} + TChunkedInput ci(&mi); + TransferData(&ci, &Cnull); + } catch (...) { + hasError = true; + } + + UNIT_ASSERT(hasError); + } +} |