diff options
author | Arseny Smalyuk <smalukav@gmail.com> | 2022-02-10 16:48:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:05 +0300 |
commit | 12559cd7f2fa0cf54ffb0d961949fea58c0e18cb (patch) | |
tree | 1c6e1bb383ce1ed8ea168386f913410dd55ccb7f /util/stream/zlib_ut.cpp | |
parent | 5b8d95df2f0cfca4d3f5499a4259aa2050ef1571 (diff) | |
download | ydb-12559cd7f2fa0cf54ffb0d961949fea58c0e18cb.tar.gz |
Restoring authorship annotation for Arseny Smalyuk <smalukav@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/stream/zlib_ut.cpp')
-rw-r--r-- | util/stream/zlib_ut.cpp | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp index 2290b4a9dee..a03904fe3df 100644 --- a/util/stream/zlib_ut.cpp +++ b/util/stream/zlib_ut.cpp @@ -52,14 +52,14 @@ private: }; Y_UNIT_TEST_SUITE(TZLibTest) { - static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; - static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv"; + static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; + static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv"; Y_UNIT_TEST(Compress) { TUnbufferedFileOutput o(ZDATA); TZLibCompress c(&o, ZLib::ZLib); - c.Write(DATA.data(), DATA.size()); + c.Write(DATA.data(), DATA.size()); c.Finish(); o.Finish(); } @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) { TUnbufferedFileInput i(ZDATA); TZLibDecompress d(&i); - UNIT_ASSERT_EQUAL(d.ReadAll(), DATA); + UNIT_ASSERT_EQUAL(d.ReadAll(), DATA); } } @@ -96,10 +96,10 @@ Y_UNIT_TEST_SUITE(TZLibTest) { { TUnbufferedFileOutput o(ZDATA); TZLibCompress c1(&o, ZLib::ZLib); - c1.Write(DATA.data(), DATA.size()); + c1.Write(DATA.data(), DATA.size()); c1.Finish(); TZLibCompress c2(&o, ZLib::ZLib); - c2.Write(DATA2.data(), DATA2.size()); + c2.Write(DATA2.data(), DATA2.size()); c2.Finish(); o.Finish(); } @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) { TUnbufferedFileInput i(ZDATA); TZLibDecompress d(&i); - UNIT_ASSERT_EQUAL(d.ReadAll(), DATA + DATA2); + UNIT_ASSERT_EQUAL(d.ReadAll(), DATA + DATA2); } } @@ -132,10 +132,10 @@ Y_UNIT_TEST_SUITE(TZLibTest) { { TUnbufferedFileOutput o(ZDATA); TZLibCompress c1(&o, ZLib::ZLib); - c1.Write(DATA.data(), DATA.size()); + c1.Write(DATA.data(), DATA.size()); c1.Finish(); TZLibCompress c2(&o, ZLib::ZLib); - c2.Write(DATA2.data(), DATA2.size()); + c2.Write(DATA2.data(), DATA2.size()); c2.Finish(); o.Finish(); } @@ -144,87 +144,87 @@ Y_UNIT_TEST_SUITE(TZLibTest) { TZLibDecompress d(&i); d.SetAllowMultipleStreams(false); - UNIT_ASSERT_EQUAL(d.ReadAll(), DATA); - } - } - - Y_UNIT_TEST(CompressFlush) { - TString data = ""; - - for (size_t i = 0; i < 32; ++i) { - TTempFile tmpFile(ZDATA); - - TUnbufferedFileOutput output(ZDATA); - TZLibCompress compressor(&output, ZLib::ZLib); - - compressor.Write(data.data(), data.size()); - compressor.Flush(); - - { - TUnbufferedFileInput input(ZDATA); - TZLibDecompress decompressor(&input); - - UNIT_ASSERT_EQUAL(decompressor.ReadAll(), data); - } - - data += 'A' + i; - } - } - - Y_UNIT_TEST(CompressEmptyFlush) { - TTempFile tmpFile(ZDATA); - - TUnbufferedFileOutput output(ZDATA); - TZLibCompress compressor(&output, ZLib::ZLib); - - TUnbufferedFileInput input(ZDATA); - - compressor.Write(DATA.data(), DATA.size()); - compressor.Flush(); - - { - TZLibDecompress decompressor(&input); - UNIT_ASSERT_EQUAL(decompressor.ReadAll(), DATA); - } - - for (size_t i = 0; i < 10; ++i) { - compressor.Flush(); - } - - UNIT_ASSERT_EQUAL(input.ReadAll(), ""); - } - - Y_UNIT_TEST(CompressFlushSmallBuffer) { - for (size_t bufferSize = 16; bufferSize < 32; ++bufferSize) { - TString firstData = ""; - - for (size_t firstDataSize = 0; firstDataSize < 16; ++firstDataSize) { - TString secondData = ""; - - for (size_t secondDataSize = 0; secondDataSize < 16; ++secondDataSize) { - TTempFile tmpFile(ZDATA); - - TUnbufferedFileOutput output(ZDATA); - TZLibCompress compressor(TZLibCompress::TParams(&output).SetType(ZLib::ZLib).SetBufLen(bufferSize)); - - TUnbufferedFileInput input(ZDATA); - TZLibDecompress decompressor(&input); - - compressor.Write(firstData.data(), firstData.size()); - compressor.Flush(); - - UNIT_ASSERT_EQUAL(decompressor.ReadAll(), firstData); - - compressor.Write(secondData.data(), secondData.size()); - compressor.Flush(); - - UNIT_ASSERT_EQUAL(decompressor.ReadAll(), secondData); - - secondData += 'A' + secondDataSize; - } - - firstData += 'A' + firstDataSize; - } + UNIT_ASSERT_EQUAL(d.ReadAll(), DATA); } } + + Y_UNIT_TEST(CompressFlush) { + TString data = ""; + + for (size_t i = 0; i < 32; ++i) { + TTempFile tmpFile(ZDATA); + + TUnbufferedFileOutput output(ZDATA); + TZLibCompress compressor(&output, ZLib::ZLib); + + compressor.Write(data.data(), data.size()); + compressor.Flush(); + + { + TUnbufferedFileInput input(ZDATA); + TZLibDecompress decompressor(&input); + + UNIT_ASSERT_EQUAL(decompressor.ReadAll(), data); + } + + data += 'A' + i; + } + } + + Y_UNIT_TEST(CompressEmptyFlush) { + TTempFile tmpFile(ZDATA); + + TUnbufferedFileOutput output(ZDATA); + TZLibCompress compressor(&output, ZLib::ZLib); + + TUnbufferedFileInput input(ZDATA); + + compressor.Write(DATA.data(), DATA.size()); + compressor.Flush(); + + { + TZLibDecompress decompressor(&input); + UNIT_ASSERT_EQUAL(decompressor.ReadAll(), DATA); + } + + for (size_t i = 0; i < 10; ++i) { + compressor.Flush(); + } + + UNIT_ASSERT_EQUAL(input.ReadAll(), ""); + } + + Y_UNIT_TEST(CompressFlushSmallBuffer) { + for (size_t bufferSize = 16; bufferSize < 32; ++bufferSize) { + TString firstData = ""; + + for (size_t firstDataSize = 0; firstDataSize < 16; ++firstDataSize) { + TString secondData = ""; + + for (size_t secondDataSize = 0; secondDataSize < 16; ++secondDataSize) { + TTempFile tmpFile(ZDATA); + + TUnbufferedFileOutput output(ZDATA); + TZLibCompress compressor(TZLibCompress::TParams(&output).SetType(ZLib::ZLib).SetBufLen(bufferSize)); + + TUnbufferedFileInput input(ZDATA); + TZLibDecompress decompressor(&input); + + compressor.Write(firstData.data(), firstData.size()); + compressor.Flush(); + + UNIT_ASSERT_EQUAL(decompressor.ReadAll(), firstData); + + compressor.Write(secondData.data(), secondData.size()); + compressor.Flush(); + + UNIT_ASSERT_EQUAL(decompressor.ReadAll(), secondData); + + secondData += 'A' + secondDataSize; + } + + firstData += 'A' + firstDataSize; + } + } + } } |