From 614cf96bc7f7e30bd1d5d6ffc6edb6bb6287679a Mon Sep 17 00:00:00 2001 From: GUJIEJASON <1776127334@qq.com> Date: Tue, 29 Oct 2024 15:39:09 +0800 Subject: [PATCH] fix some bugs in ttl_test --- test/ttl_test.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/test/ttl_test.cc b/test/ttl_test.cc index 5c5a4c8..1ad7298 100644 --- a/test/ttl_test.cc +++ b/test/ttl_test.cc @@ -1,11 +1,7 @@ - - #include "gtest/gtest.h" - #include "leveldb/env.h" #include "leveldb/db.h" - using namespace leveldb; constexpr int value_size = 2048; @@ -20,7 +16,7 @@ Status OpenDB(std::string dbName, DB **db) { void InsertData(DB *db, uint64_t ttl/* second */) { WriteOptions writeOptions; int key_num = data_size / value_size; - srand(static_cast(time(0))); + srand(0); for (int i = 0; i < key_num; i++) { int key_ = rand() % key_num+1; @@ -35,7 +31,7 @@ void GetData(DB *db, int size = (1 << 30)) { int key_num = data_size / value_size; // 点查 - srand(static_cast(time(0))); + srand(0); for (int i = 0; i < 100; i++) { int key_ = rand() % key_num+1; std::string key = std::to_string(key_); @@ -58,7 +54,7 @@ TEST(TestTTL, ReadTTL) { ReadOptions readOptions; Status status; int key_num = data_size / value_size; - srand(static_cast(time(0))); + srand(0); for (int i = 0; i < 100; i++) { int key_ = rand() % key_num+1; std::string key = std::to_string(key_); @@ -99,9 +95,9 @@ TEST(TestTTL, CompactionTTL) { db->CompactRange(nullptr, nullptr); -// leveldb::Range ranges[1]; + // leveldb::Range ranges[1]; ranges[0] = leveldb::Range("-", "A"); -// uint64_t sizes[1]; + // uint64_t sizes[1]; db->GetApproximateSizes(ranges, 1, sizes); ASSERT_EQ(sizes[0], 0); } @@ -111,4 +107,4 @@ int main(int argc, char** argv) { // All tests currently run with the same read-only file limits. testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} +} \ No newline at end of file