diff options
author | Alexander Fokin <apfokin@gmail.com> | 2022-02-10 16:45:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:38 +0300 |
commit | bf9e69a933f89af083d895185f01ed65e4d90766 (patch) | |
tree | b2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/stream/length_ut.cpp | |
parent | 863a59a65247c24db7cb06789bc5cf79d04da32f (diff) | |
download | ydb-bf9e69a933f89af083d895185f01ed65e4d90766.tar.gz |
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/stream/length_ut.cpp')
-rw-r--r-- | util/stream/length_ut.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/util/stream/length_ut.cpp b/util/stream/length_ut.cpp index beecc0f4be..8968448954 100644 --- a/util/stream/length_ut.cpp +++ b/util/stream/length_ut.cpp @@ -1,52 +1,52 @@ -#include "length.h" - +#include "length.h" + #include <library/cpp/testing/unittest/registar.h> - + #include <util/generic/string.h> - + Y_UNIT_TEST_SUITE(TestLengthIO) { Y_UNIT_TEST(TestLengthLimitedInput) { - char buf[16]; - - TStringStream s1("abcd"); - TLengthLimitedInput l1(&s1, 2); - UNIT_ASSERT_VALUES_EQUAL(l1.Load(buf, 3), 2); - UNIT_ASSERT_VALUES_EQUAL(l1.Read(buf, 1), 0); - } - + char buf[16]; + + TStringStream s1("abcd"); + TLengthLimitedInput l1(&s1, 2); + UNIT_ASSERT_VALUES_EQUAL(l1.Load(buf, 3), 2); + UNIT_ASSERT_VALUES_EQUAL(l1.Read(buf, 1), 0); + } + Y_UNIT_TEST(TestCountingInput) { - char buf[16]; - - TStringStream s1("abc\ndef\n"); - TCountingInput l1(&s1); - + char buf[16]; + + TStringStream s1("abc\ndef\n"); + TCountingInput l1(&s1); + TString s; - l1.ReadLine(s); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 4); - - l1.Load(buf, 1); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 5); - - l1.Skip(1); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 6); - - l1.ReadLine(s); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 8); - } - + l1.ReadLine(s); + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 4); + + l1.Load(buf, 1); + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 5); + + l1.Skip(1); + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 6); + + l1.ReadLine(s); + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 8); + } + Y_UNIT_TEST(TestCountingOutput) { - TStringStream s1; - TCountingOutput l1(&s1); - - l1.Write('1'); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 1); - + TStringStream s1; + TCountingOutput l1(&s1); + + l1.Write('1'); + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 1); + l1.Write(TString("abcd")); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 5); - + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 5); + TString buf("aaa"); IOutputStream::TPart parts[] = {{buf.data(), buf.size()}, {buf.data(), buf.size()}, {buf.data(), buf.size()}}; - l1.Write(parts, 3); - UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 14); - } -} + l1.Write(parts, 3); + UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 14); + } +} |