diff options
author | dimko <dimko@yandex-team.ru> | 2022-02-10 16:50:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:07 +0300 |
commit | 811ece47d06924d20a94f89d1b0f5cd37254a49c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic/bitmap_ut.cpp | |
parent | 5df1bbceafd25528f800dbe399738150b20384f3 (diff) | |
download | ydb-811ece47d06924d20a94f89d1b0f5cd37254a49c.tar.gz |
Restoring authorship annotation for <dimko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/bitmap_ut.cpp')
-rw-r--r-- | util/generic/bitmap_ut.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/util/generic/bitmap_ut.cpp b/util/generic/bitmap_ut.cpp index 9cf0cc33a10..087d34a8dcc 100644 --- a/util/generic/bitmap_ut.cpp +++ b/util/generic/bitmap_ut.cpp @@ -1,7 +1,7 @@ #include "bitmap.h" #include <library/cpp/testing/unittest/registar.h> - + #define INIT_BITMAP(bitmap, bits) \ for (size_t i = 0; i < sizeof(bits) / sizeof(size_t); ++i) { \ bitmap.Set(bits[i]); \ @@ -40,23 +40,23 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { Y_UNIT_TEST(TestBitMap) { TBitMap<101> bitmap; - + UNIT_ASSERT_EQUAL(bitmap.Size(), 101); - UNIT_ASSERT_EQUAL(bitmap.Count(), 0); - UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 101); - + UNIT_ASSERT_EQUAL(bitmap.Count(), 0); + UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 101); + size_t initBits[] = {0, 50, 100, 45}; INIT_BITMAP(bitmap, initBits); - bitmap.Reset(45); - - UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 0); + bitmap.Reset(45); + + UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 0); size_t setBits[] = {0, 50, 100}; CHECK_BITMAP(bitmap, setBits); - + for (size_t i = 0; i < bitmap.Size(); ++i) { UNIT_ASSERT_EQUAL(bitmap.Get(i), bitmap.Test(i)); } - + UNIT_ASSERT_EQUAL(bitmap.Count(), 3); bitmap.Reset(0); @@ -87,51 +87,51 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { CHECK_BITMAP(bitmap, setBits); for (size_t i = 0; i < bitmap.Size(); ++i) { - UNIT_ASSERT_EQUAL(bitmap.Get(i), bitmap.Test(i)); + UNIT_ASSERT_EQUAL(bitmap.Get(i), bitmap.Test(i)); } - - UNIT_ASSERT_EQUAL(bitmap.Count(), 3); - - bitmap.Reset(0); - - UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 50); - - bitmap.Clear(); - - UNIT_ASSERT_EQUAL(bitmap.Count(), 0); + + UNIT_ASSERT_EQUAL(bitmap.Count(), 3); + + bitmap.Reset(0); + + UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 50); + + bitmap.Clear(); + + UNIT_ASSERT_EQUAL(bitmap.Count(), 0); UNIT_ASSERT_EQUAL(bitmap.Empty(), true); - } - + } + template <class TBitMapImpl> void TestAndImpl() { TBitMapImpl bitmap1; TBitMapImpl bitmap2; - + size_t initBits1[] = {10, 20, 50, 100}; size_t initBits2[] = {10, 11, 22, 50}; INIT_BITMAP(bitmap1, initBits1); INIT_BITMAP(bitmap2, initBits2); - bitmap1.And(bitmap2); - - UNIT_ASSERT_EQUAL(bitmap1.Count(), 2); - UNIT_ASSERT_EQUAL(bitmap2.Count(), 4); - + bitmap1.And(bitmap2); + + UNIT_ASSERT_EQUAL(bitmap1.Count(), 2); + UNIT_ASSERT_EQUAL(bitmap2.Count(), 4); + size_t resBits[] = {10, 50}; - + CHECK_BITMAP(bitmap1, resBits); CHECK_BITMAP(bitmap2, initBits2); - } - + } + Y_UNIT_TEST(TestAndFixed) { TestAndImpl<TBitMap<101>>(); } - + Y_UNIT_TEST(TestAndDyn) { TestAndImpl<TDynBitMap>(); } - + template <class TBitMapImpl> void TestOrImpl() { TBitMapImpl bitmap1; @@ -143,13 +143,13 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { INIT_BITMAP(bitmap1, initBits1); INIT_BITMAP(bitmap2, initBits2); - bitmap1.Or(bitmap2); - - UNIT_ASSERT_EQUAL(bitmap1.Count(), 7); - UNIT_ASSERT_EQUAL(bitmap2.Count(), 4); - + bitmap1.Or(bitmap2); + + UNIT_ASSERT_EQUAL(bitmap1.Count(), 7); + UNIT_ASSERT_EQUAL(bitmap2.Count(), 4); + size_t resBits[] = {0, 1, 10, 11, 22, 50, 76}; - + CHECK_BITMAP(bitmap1, resBits); CHECK_BITMAP(bitmap2, initBits2); @@ -548,7 +548,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { bitmapDynamic.Set(128); UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash()); } - + Y_UNIT_TEST(TestSetResetRange) { // Single chunk using TBitMap1Chunk = TBitMap<64>; |