aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers/bitseq/bitvector_ut.cpp
diff options
context:
space:
mode:
authorpkalinnikov <pkalinnikov@yandex-team.ru>2022-02-10 16:50:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:15 +0300
commit9e33e026829d561d6fd46d72b88c367952e08075 (patch)
tree2af190fca83ac522e9a7e29de1daae32582064b4 /library/cpp/containers/bitseq/bitvector_ut.cpp
parentba5325cc01aabb81effc91ff1bdbb461313cbd00 (diff)
downloadydb-9e33e026829d561d6fd46d72b88c367952e08075.tar.gz
Restoring authorship annotation for <pkalinnikov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers/bitseq/bitvector_ut.cpp')
-rw-r--r--library/cpp/containers/bitseq/bitvector_ut.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/library/cpp/containers/bitseq/bitvector_ut.cpp b/library/cpp/containers/bitseq/bitvector_ut.cpp
index 6137adab1e..e0598dbceb 100644
--- a/library/cpp/containers/bitseq/bitvector_ut.cpp
+++ b/library/cpp/containers/bitseq/bitvector_ut.cpp
@@ -1,71 +1,71 @@
-#include "bitvector.h"
+#include "bitvector.h"
#include "readonly_bitvector.h"
-
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/memory/blob.h>
#include <util/stream/buffer.h>
Y_UNIT_TEST_SUITE(TBitVectorTest) {
Y_UNIT_TEST(TestEmpty) {
- TBitVector<ui64> v64;
- UNIT_ASSERT_EQUAL(v64.Size(), 0);
- UNIT_ASSERT_EQUAL(v64.Words(), 0);
-
- TBitVector<ui32> v32(0);
- UNIT_ASSERT_EQUAL(v32.Size(), 0);
- UNIT_ASSERT_EQUAL(v32.Words(), 0);
- }
-
+ TBitVector<ui64> v64;
+ UNIT_ASSERT_EQUAL(v64.Size(), 0);
+ UNIT_ASSERT_EQUAL(v64.Words(), 0);
+
+ TBitVector<ui32> v32(0);
+ UNIT_ASSERT_EQUAL(v32.Size(), 0);
+ UNIT_ASSERT_EQUAL(v32.Words(), 0);
+ }
+
Y_UNIT_TEST(TestOneWord) {
- TBitVector<ui32> v;
- v.Append(1, 1);
- v.Append(0, 1);
- v.Append(1, 3);
- v.Append(10, 4);
- v.Append(100500, 20);
-
- UNIT_ASSERT_EQUAL(v.Get(0, 1), 1);
- UNIT_ASSERT(v.Test(0));
- UNIT_ASSERT_EQUAL(v.Get(1, 1), 0);
- UNIT_ASSERT_EQUAL(v.Get(2, 3), 1);
- UNIT_ASSERT_EQUAL(v.Get(5, 4), 10);
- UNIT_ASSERT_EQUAL(v.Get(9, 20), 100500);
-
- v.Reset(0);
- v.Set(9, 1234, 15);
- UNIT_ASSERT_EQUAL(v.Get(0, 1), 0);
- UNIT_ASSERT(!v.Test(0));
- UNIT_ASSERT_EQUAL(v.Get(9, 15), 1234);
-
- UNIT_ASSERT_EQUAL(v.Size(), 29);
- UNIT_ASSERT_EQUAL(v.Words(), 1);
- }
-
+ TBitVector<ui32> v;
+ v.Append(1, 1);
+ v.Append(0, 1);
+ v.Append(1, 3);
+ v.Append(10, 4);
+ v.Append(100500, 20);
+
+ UNIT_ASSERT_EQUAL(v.Get(0, 1), 1);
+ UNIT_ASSERT(v.Test(0));
+ UNIT_ASSERT_EQUAL(v.Get(1, 1), 0);
+ UNIT_ASSERT_EQUAL(v.Get(2, 3), 1);
+ UNIT_ASSERT_EQUAL(v.Get(5, 4), 10);
+ UNIT_ASSERT_EQUAL(v.Get(9, 20), 100500);
+
+ v.Reset(0);
+ v.Set(9, 1234, 15);
+ UNIT_ASSERT_EQUAL(v.Get(0, 1), 0);
+ UNIT_ASSERT(!v.Test(0));
+ UNIT_ASSERT_EQUAL(v.Get(9, 15), 1234);
+
+ UNIT_ASSERT_EQUAL(v.Size(), 29);
+ UNIT_ASSERT_EQUAL(v.Words(), 1);
+ }
+
Y_UNIT_TEST(TestManyWords) {
- static const int BITS = 10;
- TBitVector<ui64> v;
-
- for (int i = 0, end = (1 << BITS); i < end; ++i)
- v.Append(i, BITS);
-
- UNIT_ASSERT_EQUAL(v.Size(), BITS * (1 << BITS));
- UNIT_ASSERT_EQUAL(v.Words(), (v.Size() + 63) / 64);
- for (int i = 0, end = (1 << BITS); i < end; ++i)
- UNIT_ASSERT_EQUAL(v.Get(i * BITS, BITS), (ui64)i);
- }
-
+ static const int BITS = 10;
+ TBitVector<ui64> v;
+
+ for (int i = 0, end = (1 << BITS); i < end; ++i)
+ v.Append(i, BITS);
+
+ UNIT_ASSERT_EQUAL(v.Size(), BITS * (1 << BITS));
+ UNIT_ASSERT_EQUAL(v.Words(), (v.Size() + 63) / 64);
+ for (int i = 0, end = (1 << BITS); i < end; ++i)
+ UNIT_ASSERT_EQUAL(v.Get(i * BITS, BITS), (ui64)i);
+ }
+
Y_UNIT_TEST(TestMaxWordSize) {
- TBitVector<ui32> v;
- for (int i = 0; i < 100; ++i)
- v.Append(i, 32);
-
- for (int i = 0; i < 100; ++i)
- UNIT_ASSERT_EQUAL(v.Get(i * 32, 32), (ui32)i);
-
- v.Set(10 * 32, 100500, 32);
- UNIT_ASSERT_EQUAL(v.Get(10 * 32, 32), 100500);
- }
+ TBitVector<ui32> v;
+ for (int i = 0; i < 100; ++i)
+ v.Append(i, 32);
+
+ for (int i = 0; i < 100; ++i)
+ UNIT_ASSERT_EQUAL(v.Get(i * 32, 32), (ui32)i);
+
+ v.Set(10 * 32, 100500, 32);
+ UNIT_ASSERT_EQUAL(v.Get(10 * 32, 32), 100500);
+ }
Y_UNIT_TEST(TestReadonlyVector) {
TBitVector<ui64> v(100);
@@ -83,4 +83,4 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) {
UNIT_ASSERT_VALUES_EQUAL(rv.Test(i), i % 3 == 0);
}
}
-}
+}