aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/streams/lzma/lzma_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/streams/lzma/lzma_ut.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/streams/lzma/lzma_ut.cpp')
-rw-r--r--library/cpp/streams/lzma/lzma_ut.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/library/cpp/streams/lzma/lzma_ut.cpp b/library/cpp/streams/lzma/lzma_ut.cpp
index 847e98d1ca..47a3aa4bf3 100644
--- a/library/cpp/streams/lzma/lzma_ut.cpp
+++ b/library/cpp/streams/lzma/lzma_ut.cpp
@@ -1,127 +1,127 @@
-#include "lzma.h"
-
+#include "lzma.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/stream/mem.h>
-#include <util/random/fast.h>
-#include <util/random/random.h>
-
+
+#include <util/stream/mem.h>
+#include <util/random/fast.h>
+#include <util/random/random.h>
+
class TStrokaByOneByte: public IZeroCopyInput {
-public:
+public:
TStrokaByOneByte(const TString& s)
- : Data(s)
- , Pos(s.data())
- {
- }
+ : Data(s)
+ , Pos(s.data())
+ {
+ }
-private:
+private:
size_t DoNext(const void** ptr, size_t len) override {
- if (Pos < Data.end()) {
+ if (Pos < Data.end()) {
len = Min(len, static_cast<size_t>(1));
*ptr = Pos;
Pos += len;
return len;
- } else {
+ } else {
return 0;
}
- }
+ }
TString Data;
- const char* Pos;
+ const char* Pos;
};
-class TLzmaTest: public TTestBase {
- UNIT_TEST_SUITE(TLzmaTest);
- UNIT_TEST(Test1)
- UNIT_TEST(Test2)
- UNIT_TEST_SUITE_END();
-
-private:
+class TLzmaTest: public TTestBase {
+ UNIT_TEST_SUITE(TLzmaTest);
+ UNIT_TEST(Test1)
+ UNIT_TEST(Test2)
+ UNIT_TEST_SUITE_END();
+
+private:
inline TString GenData() {
TString data;
- TReallyFastRng32 rnd(RandomNumber<ui64>());
-
- for (size_t i = 0; i < 50000; ++i) {
- const char ch = rnd.Uniform(256);
- const size_t len = 1 + rnd.Uniform(10);
-
+ TReallyFastRng32 rnd(RandomNumber<ui64>());
+
+ for (size_t i = 0; i < 50000; ++i) {
+ const char ch = rnd.Uniform(256);
+ const size_t len = 1 + rnd.Uniform(10);
+
data += TString(len, ch);
- }
-
- return data;
- }
-
- inline void Test2() {
+ }
+
+ return data;
+ }
+
+ inline void Test2() {
class TExcOutput: public IOutputStream {
- public:
+ public:
~TExcOutput() override {
- }
-
+ }
+
void DoWrite(const void*, size_t) override {
- throw 12345;
- }
- };
-
+ throw 12345;
+ }
+ };
+
TString data(GenData());
TMemoryInput mi(data.data(), data.size());
- TExcOutput out;
-
- try {
- TLzmaCompress c(&out);
-
+ TExcOutput out;
+
+ try {
+ TLzmaCompress c(&out);
+
TransferData(&mi, &c);
- } catch (int i) {
- UNIT_ASSERT_EQUAL(i, 12345);
- }
- }
-
- inline void Test1() {
+ } catch (int i) {
+ UNIT_ASSERT_EQUAL(i, 12345);
+ }
+ }
+
+ inline void Test1() {
TString data(GenData());
TString data1;
TString res;
-
- {
+
+ {
TMemoryInput mi(data.data(), data.size());
- TStringOutput so(res);
- TLzmaCompress c(&so);
-
+ TStringOutput so(res);
+ TLzmaCompress c(&so);
+
TransferData(&mi, &c);
-
- c.Finish();
- }
-
- {
+
+ c.Finish();
+ }
+
+ {
TMemoryInput mi(res.data(), res.size());
- TStringOutput so(data1);
+ TStringOutput so(data1);
TLzmaDecompress d((IInputStream*)&mi);
-
- TransferData(&d, &so);
- }
-
- UNIT_ASSERT_EQUAL(data, data1);
-
- data1.clear();
- {
+
+ TransferData(&d, &so);
+ }
+
+ UNIT_ASSERT_EQUAL(data, data1);
+
+ data1.clear();
+ {
TMemoryInput mi(res.data(), res.size());
- TStringOutput so(data1);
+ TStringOutput so(data1);
TLzmaDecompress d(&mi);
- TransferData(&d, &so);
- }
+ TransferData(&d, &so);
+ }
- UNIT_ASSERT_EQUAL(data, data1);
+ UNIT_ASSERT_EQUAL(data, data1);
- data1.clear();
- {
- TStrokaByOneByte mi(res);
- TStringOutput so(data1);
+ data1.clear();
+ {
+ TStrokaByOneByte mi(res);
+ TStringOutput so(data1);
TLzmaDecompress d(&mi);
- TransferData(&d, &so);
- }
-
- UNIT_ASSERT_EQUAL(data, data1);
- }
-};
+ TransferData(&d, &so);
+ }
-UNIT_TEST_SUITE_REGISTRATION(TLzmaTest);
+ UNIT_ASSERT_EQUAL(data, data1);
+ }
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TLzmaTest);