aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/aligned_ut.cpp
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commit863a59a65247c24db7cb06789bc5cf79d04da32f (patch)
tree139dc000c8cd4a40f5659e421b7c75135d080307 /util/stream/aligned_ut.cpp
parentf64e95a9eb9ab03240599eb9581c5a9102426a96 (diff)
downloadydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/stream/aligned_ut.cpp')
-rw-r--r--util/stream/aligned_ut.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/util/stream/aligned_ut.cpp b/util/stream/aligned_ut.cpp
index e980d05cf7..cf2bf6f2a7 100644
--- a/util/stream/aligned_ut.cpp
+++ b/util/stream/aligned_ut.cpp
@@ -1,63 +1,63 @@
-#include "aligned.h"
-
+#include "aligned.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
class TNastyInputStream: public IInputStream {
-public:
+public:
TNastyInputStream()
: Pos_(0)
{
}
-
-protected:
+
+protected:
size_t DoRead(void* buf, size_t len) override {
if (len == 0) {
- return 0;
+ return 0;
}
-
- *static_cast<unsigned char*>(buf) = static_cast<unsigned char>(Pos_);
+
+ *static_cast<unsigned char*>(buf) = static_cast<unsigned char>(Pos_);
++Pos_;
- return 1;
- }
-
+ return 1;
+ }
+
size_t DoSkip(size_t len) override {
if (len == 0) {
- return 0;
+ return 0;
}
-
+
++Pos_;
- return 1;
- }
-
-private:
- size_t Pos_;
-};
-
+ return 1;
+ }
+
+private:
+ size_t Pos_;
+};
+
Y_UNIT_TEST_SUITE(TAlignedTest) {
Y_UNIT_TEST(AlignInput) {
- TNastyInputStream input0;
- TAlignedInput alignedInput(&input0);
-
- char c = '\1';
-
- alignedInput.Align(2);
- alignedInput.ReadChar(c);
- UNIT_ASSERT_VALUES_EQUAL(c, '\x0');
-
- alignedInput.Align(2);
- alignedInput.ReadChar(c);
- UNIT_ASSERT_VALUES_EQUAL(c, '\x2');
-
- alignedInput.Align(4);
- alignedInput.ReadChar(c);
- UNIT_ASSERT_VALUES_EQUAL(c, '\x4');
-
- alignedInput.Align(16);
- alignedInput.ReadChar(c);
- UNIT_ASSERT_VALUES_EQUAL(c, '\x10');
-
- alignedInput.Align(128);
- alignedInput.ReadChar(c);
- UNIT_ASSERT_VALUES_EQUAL(c, '\x80');
- }
-}
+ TNastyInputStream input0;
+ TAlignedInput alignedInput(&input0);
+
+ char c = '\1';
+
+ alignedInput.Align(2);
+ alignedInput.ReadChar(c);
+ UNIT_ASSERT_VALUES_EQUAL(c, '\x0');
+
+ alignedInput.Align(2);
+ alignedInput.ReadChar(c);
+ UNIT_ASSERT_VALUES_EQUAL(c, '\x2');
+
+ alignedInput.Align(4);
+ alignedInput.ReadChar(c);
+ UNIT_ASSERT_VALUES_EQUAL(c, '\x4');
+
+ alignedInput.Align(16);
+ alignedInput.ReadChar(c);
+ UNIT_ASSERT_VALUES_EQUAL(c, '\x10');
+
+ alignedInput.Align(128);
+ alignedInput.ReadChar(c);
+ UNIT_ASSERT_VALUES_EQUAL(c, '\x80');
+ }
+}