diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/threading/chunk_queue/queue_ut.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/chunk_queue/queue_ut.cpp')
-rw-r--r-- | library/cpp/threading/chunk_queue/queue_ut.cpp | 284 |
1 files changed, 142 insertions, 142 deletions
diff --git a/library/cpp/threading/chunk_queue/queue_ut.cpp b/library/cpp/threading/chunk_queue/queue_ut.cpp index 406b71dd4c..8cb36d8dd1 100644 --- a/library/cpp/threading/chunk_queue/queue_ut.cpp +++ b/library/cpp/threading/chunk_queue/queue_ut.cpp @@ -5,55 +5,55 @@ #include <util/generic/set.h> namespace NThreading { - //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// Y_UNIT_TEST_SUITE(TOneOneQueueTest){ Y_UNIT_TEST(ShouldBeEmptyAtStart){ - TOneOneQueue<int> queue; + TOneOneQueue<int> queue; - int result = 0; - UNIT_ASSERT(queue.IsEmpty()); - UNIT_ASSERT(!queue.Dequeue(result)); -} + int result = 0; + UNIT_ASSERT(queue.IsEmpty()); + UNIT_ASSERT(!queue.Dequeue(result)); +} Y_UNIT_TEST(ShouldReturnEntries) { - TOneOneQueue<int> queue; - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); + TOneOneQueue<int> queue; + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); - int result = 0; - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 1); + int result = 0; + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 1); - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 2); + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 2); - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 3); + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 3); - UNIT_ASSERT(queue.IsEmpty()); - UNIT_ASSERT(!queue.Dequeue(result)); -} + UNIT_ASSERT(queue.IsEmpty()); + UNIT_ASSERT(!queue.Dequeue(result)); +} Y_UNIT_TEST(ShouldStoreMultipleChunks) { - TOneOneQueue<int, 100> queue; - for (int i = 0; i < 1000; ++i) { - queue.Enqueue(i); + TOneOneQueue<int, 100> queue; + for (int i = 0; i < 1000; ++i) { + queue.Enqueue(i); } - for (int i = 0; i < 1000; ++i) { - int result = 0; - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, i); + for (int i = 0; i < 1000; ++i) { + int result = 0; + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, i); } -} -} -; +} +} +; //////////////////////////////////////////////////////////////////////////////// @@ -61,35 +61,35 @@ Y_UNIT_TEST_SUITE(TManyOneQueueTest){ Y_UNIT_TEST(ShouldBeEmptyAtStart){ TManyOneQueue<int> queue; -int result; -UNIT_ASSERT(queue.IsEmpty()); -UNIT_ASSERT(!queue.Dequeue(result)); -} +int result; +UNIT_ASSERT(queue.IsEmpty()); +UNIT_ASSERT(!queue.Dequeue(result)); +} Y_UNIT_TEST(ShouldReturnEntries) { - TManyOneQueue<int> queue; - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - - int result = 0; - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 1); - - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 2); - - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 3); - - UNIT_ASSERT(queue.IsEmpty()); - UNIT_ASSERT(!queue.Dequeue(result)); -} -} -; + TManyOneQueue<int> queue; + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + + int result = 0; + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 1); + + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 2); + + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 3); + + UNIT_ASSERT(queue.IsEmpty()); + UNIT_ASSERT(!queue.Dequeue(result)); +} +} +; //////////////////////////////////////////////////////////////////////////////// @@ -97,35 +97,35 @@ Y_UNIT_TEST_SUITE(TManyManyQueueTest){ Y_UNIT_TEST(ShouldBeEmptyAtStart){ TManyManyQueue<int> queue; -int result = 0; -UNIT_ASSERT(queue.IsEmpty()); -UNIT_ASSERT(!queue.Dequeue(result)); -} +int result = 0; +UNIT_ASSERT(queue.IsEmpty()); +UNIT_ASSERT(!queue.Dequeue(result)); +} Y_UNIT_TEST(ShouldReturnEntries) { - TManyManyQueue<int> queue; - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - - int result = 0; - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 1); - - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 2); - - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT_EQUAL(result, 3); - - UNIT_ASSERT(queue.IsEmpty()); - UNIT_ASSERT(!queue.Dequeue(result)); -} -} -; + TManyManyQueue<int> queue; + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + + int result = 0; + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 1); + + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 2); + + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT_EQUAL(result, 3); + + UNIT_ASSERT(queue.IsEmpty()); + UNIT_ASSERT(!queue.Dequeue(result)); +} +} +; //////////////////////////////////////////////////////////////////////////////// @@ -133,37 +133,37 @@ Y_UNIT_TEST_SUITE(TRelaxedManyOneQueueTest){ Y_UNIT_TEST(ShouldBeEmptyAtStart){ TRelaxedManyOneQueue<int> queue; -int result; -UNIT_ASSERT(queue.IsEmpty()); -UNIT_ASSERT(!queue.Dequeue(result)); -} +int result; +UNIT_ASSERT(queue.IsEmpty()); +UNIT_ASSERT(!queue.Dequeue(result)); +} Y_UNIT_TEST(ShouldReturnEntries) { - TSet<int> items = {1, 2, 3}; + TSet<int> items = {1, 2, 3}; - TRelaxedManyOneQueue<int> queue; - for (int item : items) { - queue.Enqueue(item); - } + TRelaxedManyOneQueue<int> queue; + for (int item : items) { + queue.Enqueue(item); + } - int result = 0; - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT(items.erase(result)); + int result = 0; + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT(items.erase(result)); - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT(items.erase(result)); + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT(items.erase(result)); - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT(items.erase(result)); + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT(items.erase(result)); - UNIT_ASSERT(queue.IsEmpty()); - UNIT_ASSERT(!queue.Dequeue(result)); -} -} -; + UNIT_ASSERT(queue.IsEmpty()); + UNIT_ASSERT(!queue.Dequeue(result)); +} +} +; //////////////////////////////////////////////////////////////////////////////// @@ -171,35 +171,35 @@ Y_UNIT_TEST_SUITE(TRelaxedManyManyQueueTest){ Y_UNIT_TEST(ShouldBeEmptyAtStart){ TRelaxedManyManyQueue<int> queue; -int result = 0; -UNIT_ASSERT(queue.IsEmpty()); -UNIT_ASSERT(!queue.Dequeue(result)); -} +int result = 0; +UNIT_ASSERT(queue.IsEmpty()); +UNIT_ASSERT(!queue.Dequeue(result)); +} Y_UNIT_TEST(ShouldReturnEntries) { - TSet<int> items = {1, 2, 3}; - - TRelaxedManyManyQueue<int> queue; - for (int item : items) { - queue.Enqueue(item); - } - - int result = 0; - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT(items.erase(result)); - - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT(items.erase(result)); - - UNIT_ASSERT(!queue.IsEmpty()); - UNIT_ASSERT(queue.Dequeue(result)); - UNIT_ASSERT(items.erase(result)); - - UNIT_ASSERT(queue.IsEmpty()); - UNIT_ASSERT(!queue.Dequeue(result)); -} -} -; -} + TSet<int> items = {1, 2, 3}; + + TRelaxedManyManyQueue<int> queue; + for (int item : items) { + queue.Enqueue(item); + } + + int result = 0; + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT(items.erase(result)); + + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT(items.erase(result)); + + UNIT_ASSERT(!queue.IsEmpty()); + UNIT_ASSERT(queue.Dequeue(result)); + UNIT_ASSERT(items.erase(result)); + + UNIT_ASSERT(queue.IsEmpty()); + UNIT_ASSERT(!queue.Dequeue(result)); +} +} +; +} |