diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/memory/tempbuf_ut.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/memory/tempbuf_ut.cpp')
-rw-r--r-- | util/memory/tempbuf_ut.cpp | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/util/memory/tempbuf_ut.cpp b/util/memory/tempbuf_ut.cpp index d6bcf9d546..3c6dc5a221 100644 --- a/util/memory/tempbuf_ut.cpp +++ b/util/memory/tempbuf_ut.cpp @@ -1,69 +1,69 @@ -#include "tempbuf.h" - +#include "tempbuf.h" + #include <utility> #include <library/cpp/testing/unittest/registar.h> - -class TTempBufTest: public TTestBase { - UNIT_TEST_SUITE(TTempBufTest); - UNIT_TEST(TestCreate); - UNIT_TEST(TestOps); + +class TTempBufTest: public TTestBase { + UNIT_TEST_SUITE(TTempBufTest); + UNIT_TEST(TestCreate); + UNIT_TEST(TestOps); UNIT_TEST(TestMoveCtor); - UNIT_TEST(TestAppend); + UNIT_TEST(TestAppend); UNIT_TEST(TestProceed); - UNIT_TEST_SUITE_END(); - -public: - void TestCreate(); - void TestOps(); + UNIT_TEST_SUITE_END(); + +public: + void TestCreate(); + void TestOps(); void TestMoveCtor(); void TestProceed(); - - void TestAppend() { - TTempBuf tmp; - - tmp.Append("a", 1); - tmp.Append("bc", 2); - tmp.Append("def", 3); - - UNIT_ASSERT_EQUAL(tmp.Filled(), 6); + + void TestAppend() { + TTempBuf tmp; + + tmp.Append("a", 1); + tmp.Append("bc", 2); + tmp.Append("def", 3); + + UNIT_ASSERT_EQUAL(tmp.Filled(), 6); UNIT_ASSERT_EQUAL(TString(tmp.Data(), tmp.Filled()), "abcdef"); - } -}; - -UNIT_TEST_SUITE_REGISTRATION(TTempBufTest); - -void TTempBufTest::TestCreate() { - const size_t num = 1000000; - size_t tmp = 0; - const size_t len = 4096; - - for (size_t i = 0; i < num; ++i) { - TTempBuf buf(len); - - tmp += (size_t)buf.Data(); - } - - UNIT_ASSERT(tmp != 0); -} - -void TTempBufTest::TestOps() { - TTempBuf tmp(201); - - tmp.Proceed(100); - - UNIT_ASSERT_EQUAL(tmp.Current() - tmp.Data(), 100); - UNIT_ASSERT(tmp.Left() >= 101); - UNIT_ASSERT(tmp.Size() >= 201); - UNIT_ASSERT_EQUAL(tmp.Filled(), 100); - - tmp.Reset(); - - UNIT_ASSERT_EQUAL(tmp.Current(), tmp.Data()); - UNIT_ASSERT(tmp.Left() >= 201); - UNIT_ASSERT(tmp.Size() >= 201); - UNIT_ASSERT_EQUAL(tmp.Filled(), 0); -} + } +}; + +UNIT_TEST_SUITE_REGISTRATION(TTempBufTest); + +void TTempBufTest::TestCreate() { + const size_t num = 1000000; + size_t tmp = 0; + const size_t len = 4096; + + for (size_t i = 0; i < num; ++i) { + TTempBuf buf(len); + + tmp += (size_t)buf.Data(); + } + + UNIT_ASSERT(tmp != 0); +} + +void TTempBufTest::TestOps() { + TTempBuf tmp(201); + + tmp.Proceed(100); + + UNIT_ASSERT_EQUAL(tmp.Current() - tmp.Data(), 100); + UNIT_ASSERT(tmp.Left() >= 101); + UNIT_ASSERT(tmp.Size() >= 201); + UNIT_ASSERT_EQUAL(tmp.Filled(), 100); + + tmp.Reset(); + + UNIT_ASSERT_EQUAL(tmp.Current(), tmp.Data()); + UNIT_ASSERT(tmp.Left() >= 201); + UNIT_ASSERT(tmp.Size() >= 201); + UNIT_ASSERT_EQUAL(tmp.Filled(), 0); +} void TTempBufTest::TestMoveCtor() { TTempBuf src; |