diff options
| author | Alexey Borzenkov <[email protected]> | 2022-02-10 16:47:41 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:47:41 +0300 |
| commit | 22d92781ba2a10b7fb5b977b7d1a5c40ff53885f (patch) | |
| tree | 852611fd27f734847435b37aa5b0ad5d8b1c10ac /library/cpp/threading/skip_list | |
| parent | 667a4ee7da2e004784b9c3cfab824a81e96f4d66 (diff) | |
Restoring authorship annotation for Alexey Borzenkov <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading/skip_list')
| -rw-r--r-- | library/cpp/threading/skip_list/skiplist_ut.cpp | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/library/cpp/threading/skip_list/skiplist_ut.cpp b/library/cpp/threading/skip_list/skiplist_ut.cpp index 52fcffda661..f1f075c04cc 100644 --- a/library/cpp/threading/skip_list/skiplist_ut.cpp +++ b/library/cpp/threading/skip_list/skiplist_ut.cpp @@ -38,148 +38,148 @@ namespace NThreading { Y_UNIT_TEST_SUITE(TSkipListTest) { Y_UNIT_TEST(ShouldBeEmptyAfterCreation) { TMemoryPool pool(1024); - TSkipList<int> list(pool); + TSkipList<int> list(pool); - UNIT_ASSERT_EQUAL(list.GetSize(), 0); - } + UNIT_ASSERT_EQUAL(list.GetSize(), 0); + } Y_UNIT_TEST(ShouldAllowInsertion) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT_EQUAL(list.GetSize(), 1); - } + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT_EQUAL(list.GetSize(), 1); + } Y_UNIT_TEST(ShouldNotAllowDuplicates) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT_EQUAL(list.GetSize(), 1); + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT_EQUAL(list.GetSize(), 1); - UNIT_ASSERT(!list.Insert(12345678)); - UNIT_ASSERT_EQUAL(list.GetSize(), 1); - } + UNIT_ASSERT(!list.Insert(12345678)); + UNIT_ASSERT_EQUAL(list.GetSize(), 1); + } Y_UNIT_TEST(ShouldContainInsertedItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT(list.Contains(12345678)); - } + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT(list.Contains(12345678)); + } Y_UNIT_TEST(ShouldNotContainNotInsertedItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT(!list.Contains(87654321)); - } + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT(!list.Contains(87654321)); + } Y_UNIT_TEST(ShouldIterateAllItems) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - for (int i = 8; i > 0; --i) { - UNIT_ASSERT(list.Insert(i)); - } + for (int i = 8; i > 0; --i) { + UNIT_ASSERT(list.Insert(i)); + } - TSkipList<int>::TIterator it = list.SeekToFirst(); - for (int i = 1; i <= 8; ++i) { - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), i); - it.Next(); - } - UNIT_ASSERT(!it.IsValid()); - } + TSkipList<int>::TIterator it = list.SeekToFirst(); + for (int i = 1; i <= 8; ++i) { + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), i); + it.Next(); + } + UNIT_ASSERT(!it.IsValid()); + } Y_UNIT_TEST(ShouldIterateAllItemsInReverseDirection) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - for (int i = 8; i > 0; --i) { - UNIT_ASSERT(list.Insert(i)); - } + for (int i = 8; i > 0; --i) { + UNIT_ASSERT(list.Insert(i)); + } - TSkipList<int>::TIterator it = list.SeekToLast(); - for (int i = 8; i > 0; --i) { - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), i); - it.Prev(); - } - UNIT_ASSERT(!it.IsValid()); - } + TSkipList<int>::TIterator it = list.SeekToLast(); + for (int i = 8; i > 0; --i) { + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), i); + it.Prev(); + } + UNIT_ASSERT(!it.IsValid()); + } Y_UNIT_TEST(ShouldSeekToFirstItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - for (int i = 1; i < 10; ++i) { - UNIT_ASSERT(list.Insert(i)); - } + for (int i = 1; i < 10; ++i) { + UNIT_ASSERT(list.Insert(i)); + } - TSkipList<int>::TIterator it = list.SeekToFirst(); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 1); - } + TSkipList<int>::TIterator it = list.SeekToFirst(); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 1); + } Y_UNIT_TEST(ShouldSeekToLastItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - for (int i = 1; i < 10; ++i) { - UNIT_ASSERT(list.Insert(i)); - } + for (int i = 1; i < 10; ++i) { + UNIT_ASSERT(list.Insert(i)); + } - TSkipList<int>::TIterator it = list.SeekToLast(); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 9); - } + TSkipList<int>::TIterator it = list.SeekToLast(); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 9); + } Y_UNIT_TEST(ShouldSeekToExistingItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT(list.Insert(12345678)); - TSkipList<int>::TIterator it = list.SeekTo(12345678); - UNIT_ASSERT(it.IsValid()); - } + TSkipList<int>::TIterator it = list.SeekTo(12345678); + UNIT_ASSERT(it.IsValid()); + } Y_UNIT_TEST(ShouldSeekAfterMissedItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(100)); - UNIT_ASSERT(list.Insert(300)); + UNIT_ASSERT(list.Insert(100)); + UNIT_ASSERT(list.Insert(300)); - TSkipList<int>::TIterator it = list.SeekTo(200); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 300); + TSkipList<int>::TIterator it = list.SeekTo(200); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 300); - it.Prev(); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 100); - } + it.Prev(); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 100); + } Y_UNIT_TEST(ShouldCallDtorsOfNonPodTypes) { - UNIT_ASSERT(!TTypeTraits<TTestObject>::IsPod); - UNIT_ASSERT_EQUAL(TTestObject::Count, 0); - - { - TMemoryPool pool(1024); - TSkipList<TTestObject> list(pool); + UNIT_ASSERT(!TTypeTraits<TTestObject>::IsPod); + UNIT_ASSERT_EQUAL(TTestObject::Count, 0); - UNIT_ASSERT(list.Insert(TTestObject(1))); - UNIT_ASSERT(list.Insert(TTestObject(2))); + { + TMemoryPool pool(1024); + TSkipList<TTestObject> list(pool); - UNIT_ASSERT_EQUAL(TTestObject::Count, 2); - } + UNIT_ASSERT(list.Insert(TTestObject(1))); + UNIT_ASSERT(list.Insert(TTestObject(2))); - UNIT_ASSERT_EQUAL(TTestObject::Count, 0); - } + UNIT_ASSERT_EQUAL(TTestObject::Count, 2); + } + + UNIT_ASSERT_EQUAL(TTestObject::Count, 0); + } } } |
