引入位图

This commit is contained in:
2024-09-07 20:51:43 +08:00
parent 578515d65f
commit 862d175462
4 changed files with 94 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
#include <iomanip>
#include <gtest/gtest.h>
#include <mutex/shared_mutex.h>
#include <Bitmap.h>
class RedBlackTree : public ling::RedBlackTree<unsigned long long> {
protected:
@@ -257,3 +258,16 @@ TEST(红黑树, 搜索测试) {
ASSERT_FALSE(node == nullptr);
ASSERT_EQ(node->value, 50);
}
TEST(, ) {
ling::Bitmap bitmap(100);
for (int i = 0; i < bitmap.getSize(); i++)
ASSERT_FALSE(bitmap.test(i)) << "i = " << i;
bitmap.set(20);
ASSERT_TRUE(bitmap.test(20));
ASSERT_FALSE(bitmap.test(19));
ASSERT_FALSE(bitmap.test(21));
bitmap.clear(20);
for (int i = 0; i < bitmap.getSize(); i++)
ASSERT_FALSE(bitmap.test(i));
}