From 744f6768930ab8438b3761f7ca69cc3f560d402f Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 7 Mar 2022 12:27:09 +0800 Subject: [PATCH] test --- source/libs/index/test/indexTests.cc | 45 +++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/source/libs/index/test/indexTests.cc b/source/libs/index/test/indexTests.cc index 3f46a042ae..ce3f7fe25e 100644 --- a/source/libs/index/test/indexTests.cc +++ b/source/libs/index/test/indexTests.cc @@ -1058,7 +1058,7 @@ TEST_F(IndexEnv2, testIndex_read_performance4) { std::cout << "reader sz: " << index->SearchOne("tag1", "Hello") << std::endl; assert(3 == index->SearchOne("tag10", "Hello")); } -TEST_F(IndexEnv2, testIndex_del) { +TEST_F(IndexEnv2, testIndex_cache_del) { std::string path = "/tmp/cache_and_tfile"; if (index->Init(path) != 0) { } @@ -1068,9 +1068,46 @@ TEST_F(IndexEnv2, testIndex_del) { index->Del("tag10", "Hello", 12); index->Del("tag10", "Hello", 11); - index->WriteMultiMillonData("tag10", "xxxxxxxxxxxxxx", 100 * 10000); + // index->WriteMultiMillonData("tag10", "xxxxxxxxxxxxxx", 100 * 10000); + index->Del("tag10", "Hello", 17); + EXPECT_EQ(97, index->SearchOne("tag10", "Hello")); + index->PutOneTarge("tag10", "Hello", 17); // add again EXPECT_EQ(98, index->SearchOne("tag10", "Hello")); - // std::cout << "reader sz: " << index->SearchOne("tag1", "Hello") << std::endl; - // assert(3 == index->SearchOne("tag10", "Hello")); + + // del all + for (int i = 0; i < 200; i++) { + index->Del("tag10", "Hello", i); + } + EXPECT_EQ(0, index->SearchOne("tag10", "Hello")); + + // add other item + for (int i = 0; i < 2000; i++) { + index->PutOneTarge("tag10", "World", i); + } + + for (int i = 0; i < 2000; i++) { + index->PutOneTarge("tag10", "Hello", i); + } + EXPECT_EQ(2000, index->SearchOne("tag10", "Hello")); + + for (int i = 0; i < 2000; i++) { + index->Del("tag10", "Hello", i); + } + EXPECT_EQ(0, index->SearchOne("tag10", "Hello")); +} + +TEST_F(IndexEnv2, testIndex_del) { + std::string path = "/tmp/cache_and_tfile"; + if (index->Init(path) != 0) { + } + for (int i = 0; i < 100; i++) { + index->PutOneTarge("tag10", "Hello", i); + } + index->Del("tag10", "Hello", 12); + index->Del("tag10", "Hello", 11); + + index->WriteMultiMillonData("tag10", "xxxxxxxxxxxxxx", 100 * 10000); + index->Del("tag10", "Hello", 17); + EXPECT_EQ(97, index->SearchOne("tag10", "Hello")); } -- GitLab