diff options
author | levysotsky <levysotsky@yandex-team.ru> | 2022-02-10 16:47:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:29 +0300 |
commit | 32b231c8474a1ade4bdf776ade6a20341691d9d7 (patch) | |
tree | 9814fbd1c3effac9b8377c5d604b367b14e2db55 /library/cpp/streams/brotli/brotli_ut.cpp | |
parent | 57f874ffc2a75047c1c4fea7a9fc86cb0f56ed50 (diff) | |
download | ydb-32b231c8474a1ade4bdf776ade6a20341691d9d7.tar.gz |
Restoring authorship annotation for <levysotsky@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/streams/brotli/brotli_ut.cpp')
-rw-r--r-- | library/cpp/streams/brotli/brotli_ut.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/streams/brotli/brotli_ut.cpp b/library/cpp/streams/brotli/brotli_ut.cpp index 2d07943226..aeb2e284dc 100644 --- a/library/cpp/streams/brotli/brotli_ut.cpp +++ b/library/cpp/streams/brotli/brotli_ut.cpp @@ -1,9 +1,9 @@ -#include "brotli.h" - +#include "brotli.h" + #include <library/cpp/testing/unittest/registar.h> - -#include <util/random/fast.h> - + +#include <util/random/fast.h> + Y_UNIT_TEST_SUITE(TBrotliTestSuite) { TString Compress(TString data) { TString compressed; @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { output.Finish(); return compressed; } - + TString Decompress(TString data) { TStringInput input(data); TBrotliDecompress decompressStream(&input); @@ -27,20 +27,20 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { TString GenerateRandomString(size_t size) { TReallyFastRng32 rng(42); - TString result; - result.reserve(size + sizeof(ui64)); - while (result.size() < size) { - ui64 value = rng.GenRand64(); - result += TStringBuf(reinterpret_cast<const char*>(&value), sizeof(value)); - } - result.resize(size); - return result; - } - + TString result; + result.reserve(size + sizeof(ui64)); + while (result.size() < size) { + ui64 value = rng.GenRand64(); + result += TStringBuf(reinterpret_cast<const char*>(&value), sizeof(value)); + } + result.resize(size); + return result; + } + Y_UNIT_TEST(TestHelloWorld) { TestCase("hello world"); - } - + } + Y_UNIT_TEST(TestFlush) { TStringStream ss; TBrotliCompress compressStream(&ss); @@ -64,26 +64,26 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { auto c1 = Compress(s1); auto c2 = Compress(s2); UNIT_ASSERT_VALUES_EQUAL(s1 + s2, Decompress(c1 + c2)); - } - + } + Y_UNIT_TEST(TestIncompleteStream) { TString manyAs(64 * 1024, 'a'); auto compressed = Compress(manyAs); TString truncated(compressed.data(), compressed.size() - 1); UNIT_CHECK_GENERATED_EXCEPTION(Decompress(truncated), std::exception); - } - + } + Y_UNIT_TEST(Test64KB) { auto manyAs = TString(64 * 1024, 'a'); TString str("Hello from the Matrix!@#% How are you?}{\n\t\a"); TestCase(manyAs + str + manyAs); - } - + } + Y_UNIT_TEST(Test1MB) { TestCase(GenerateRandomString(1 * 1024 * 1024)); } Y_UNIT_TEST(TestEmpty) { TestCase(""); - } -} + } +} |