diff options
author | prime <prime@yandex-team.ru> | 2022-02-10 16:46:00 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:00 +0300 |
commit | 3695a7cd42b74a4987d8d5a8f2e2443556998943 (patch) | |
tree | ee79ee9294a61ee00e647684b3700d0a87e102a3 /util/stream | |
parent | 4d8b546b89b5afc08cf3667e176271c7ba935f33 (diff) | |
download | ydb-3695a7cd42b74a4987d8d5a8f2e2443556998943.tar.gz |
Restoring authorship annotation for <prime@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/stream')
-rw-r--r-- | util/stream/zlib.cpp | 8 | ||||
-rw-r--r-- | util/stream/zlib_ut.cpp | 118 |
2 files changed, 63 insertions, 63 deletions
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp index 60f4e9439f..605143aa0e 100644 --- a/util/stream/zlib.cpp +++ b/util/stream/zlib.cpp @@ -233,10 +233,10 @@ public: const Bytef* b = (const Bytef*)buf; const Bytef* e = b + size; - Y_DEFER { - Z()->next_in = nullptr; - Z()->avail_in = 0; - }; + Y_DEFER { + Z()->next_in = nullptr; + Z()->avail_in = 0; + }; do { b = WritePart(b, e); } while (b < e); diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp index 2290b4a9de..424a422fda 100644 --- a/util/stream/zlib_ut.cpp +++ b/util/stream/zlib_ut.cpp @@ -4,53 +4,53 @@ #include "file.h" #include <util/system/tempfile.h> -#include <util/random/entropy.h> -#include <util/random/random.h> +#include <util/random/entropy.h> +#include <util/random/random.h> #define ZDATA "./zdata" -class TThrowingStream: public IOutputStream { -public: - TThrowingStream(int limit) - : Limit_(limit) - { - } - - void DoWrite(const void*, size_t size) override { - if (Ignore) { - return; - } - - Limit_ -= size; - if (Limit_ < 0) { - throw yexception() << "catch this"; - } - } - - void DoFinish() override { - if (Ignore) { - return; - } - if (Limit_ < 0) { - throw yexception() << "catch this"; - } - } - - void DoFlush() override { - if (Ignore) { - return; - } - if (Limit_ < 0) { - throw yexception() << "catch this"; - } - } - - bool Ignore = false; - -private: - int Limit_; -}; - +class TThrowingStream: public IOutputStream { +public: + TThrowingStream(int limit) + : Limit_(limit) + { + } + + void DoWrite(const void*, size_t size) override { + if (Ignore) { + return; + } + + Limit_ -= size; + if (Limit_ < 0) { + throw yexception() << "catch this"; + } + } + + void DoFinish() override { + if (Ignore) { + return; + } + if (Limit_ < 0) { + throw yexception() << "catch this"; + } + } + + void DoFlush() override { + if (Ignore) { + return; + } + if (Limit_ < 0) { + throw yexception() << "catch this"; + } + } + + bool Ignore = false; + +private: + int Limit_; +}; + Y_UNIT_TEST_SUITE(TZLibTest) { static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv"; @@ -111,21 +111,21 @@ Y_UNIT_TEST_SUITE(TZLibTest) { } } - Y_UNIT_TEST(CompressionExceptionSegfault) { - TVector<char> buf(512 * 1024); - EntropyPool().Load(buf.data(), buf.size()); - - TThrowingStream o(128 * 1024); - TZLibCompress c(&o, ZLib::GZip, 4, 1 << 15); - try { - c.Write(buf.data(), buf.size()); - } catch (...) { - } - - o.Ignore = true; - TVector<char>().swap(buf); - } - + Y_UNIT_TEST(CompressionExceptionSegfault) { + TVector<char> buf(512 * 1024); + EntropyPool().Load(buf.data(), buf.size()); + + TThrowingStream o(128 * 1024); + TZLibCompress c(&o, ZLib::GZip, 4, 1 << 15); + try { + c.Write(buf.data(), buf.size()); + } catch (...) { + } + + o.Ignore = true; + TVector<char>().swap(buf); + } + Y_UNIT_TEST(DecompressFirstOfTwoStreams) { // Check that Decompress(Compress(X) + Compress(Y)) == X when single stream is allowed TTempFile tmpFile(ZDATA); |