Skip to content

Commit a08b1c5

Browse files
Changes in Test case (#730)
1 parent 0d4e3f8 commit a08b1c5

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

test/primer/hyperloglog_test.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <iostream>
21
#include <limits>
32
#include <memory>
43
#include <string>
@@ -12,7 +11,7 @@
1211

1312
namespace bustub {
1413

15-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest1) {
14+
TEST(HyperLogLogTest, DISABLED_BasicTest1) {
1615
auto obj = HyperLogLog<std::string>(static_cast<uint64_t>(1));
1716

1817
ASSERT_EQ(obj.GetCardinality(), 0);
@@ -22,7 +21,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest1) {
2221
obj.ComputeCardinality();
2322
auto ans = obj.GetCardinality();
2423

25-
ASSERT_EQ(ans, 0);
24+
ASSERT_EQ(ans, 2);
2625

2726
for (uint64_t i = 0; i < 10; i++) {
2827
obj.AddElem("Andy");
@@ -46,7 +45,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest1) {
4645
ASSERT_EQ(ans, 12);
4746
}
4847

49-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
48+
TEST(HyperLogLogTest, DISABLED_BasicTest2) {
5049
auto obj = HyperLogLog<int64_t>(static_cast<uint64_t>(3));
5150

5251
ASSERT_EQ(obj.GetCardinality(), 0);
@@ -56,7 +55,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
5655
obj.ComputeCardinality();
5756
auto ans = obj.GetCardinality();
5857

59-
ASSERT_EQ(ans, 0);
58+
ASSERT_EQ(ans, 6);
6059

6160
for (uint64_t i = 0; i < 10; i++) {
6261
obj.AddElem(1);
@@ -71,7 +70,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
7170
if (i == 0) {
7271
obj.ComputeCardinality();
7372
ans = obj.GetCardinality();
74-
ASSERT_EQ(ans, 0);
73+
ASSERT_EQ(ans, 13);
7574
}
7675
}
7776

@@ -88,21 +87,21 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
8887
if (i == 0) {
8988
obj.ComputeCardinality();
9089
ans = obj.GetCardinality();
91-
ASSERT_EQ(ans, 0);
90+
ASSERT_EQ(ans, 15);
9291
}
9392
}
9493
obj.ComputeCardinality();
9594
ans = obj.GetCardinality();
96-
ASSERT_EQ(ans, 0);
95+
ASSERT_EQ(ans, 15);
9796
}
9897

99-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_EdgeTest1) {
98+
TEST(HyperLogLogTest, DISABLED_EdgeTest1) {
10099
auto obj1 = HyperLogLog<int64_t>(-2);
101100
obj1.ComputeCardinality();
102101
ASSERT_EQ(obj1.GetCardinality(), 0);
103102
}
104103

105-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_Edgetest2) {
104+
TEST(HyperLogLogTest, DISABLED_Edgetest2) {
106105
auto obj1 = HyperLogLog<int64_t>(0);
107106
obj1.ComputeCardinality();
108107
ASSERT_EQ(obj1.GetCardinality(), 0);
@@ -116,7 +115,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_Edgetest2) {
116115
ASSERT_EQ(obj1.GetCardinality(), 3);
117116
}
118117

119-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicParallelTest) {
118+
TEST(HyperLogLogTest, DISABLED_BasicParallelTest) {
120119
auto obj = HyperLogLog<std::string>(static_cast<uint64_t>(1));
121120

122121
std::vector<std::thread> threads1;
@@ -130,7 +129,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicParallelTest) {
130129
}
131130
obj.ComputeCardinality();
132131
auto ans = obj.GetCardinality();
133-
ASSERT_EQ(ans, 0);
132+
ASSERT_EQ(ans, 2);
134133

135134
std::vector<std::thread> threads2;
136135
for (uint16_t k = 0; k < 10; k++) {
@@ -154,7 +153,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicParallelTest) {
154153
ASSERT_EQ(ans, 12);
155154
}
156155

157-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_ParallelTest1) {
156+
TEST(HyperLogLogTest, DISABLED_ParallelTest1) {
158157
auto obj = HyperLogLog<std::string>(static_cast<uint64_t>(17));
159158

160159
std::vector<std::thread> threads1;
@@ -168,7 +167,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_ParallelTest1) {
168167
}
169168
obj.ComputeCardinality();
170169
auto ans = obj.GetCardinality();
171-
ASSERT_EQ(ans, 0);
170+
ASSERT_EQ(ans, 104074);
172171

173172
std::vector<std::thread> threads2;
174173
for (uint64_t k = 0; k < 3000; k++) {
@@ -184,10 +183,10 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_ParallelTest1) {
184183

185184
obj.ComputeCardinality();
186185
ans = obj.GetCardinality();
187-
ASSERT_EQ(ans, 0);
186+
ASSERT_EQ(ans, 104076);
188187
}
189188

190-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoBasicTest1) {
189+
TEST(HyperLogLogTest, DISABLED_PrestoBasicTest1) {
191190
auto obj = HyperLogLogPresto<std::string>(2);
192191
ASSERT_EQ(obj.GetCardinality(), 0);
193192

@@ -220,7 +219,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoBasicTest1) {
220219
ASSERT_EQ(ans, 8);
221220
}
222221

223-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoCase1) {
222+
TEST(HyperLogLogTest, DISABLED_PrestoCase1) {
224223
auto obj = HyperLogLogPresto<int64_t>(static_cast<uint64_t>(1));
225224
auto ans = obj.GetCardinality();
226225

@@ -276,7 +275,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoCase1) {
276275
ASSERT_EQ(15UL, expected5[1].to_ulong());
277276
}
278277

279-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoCase2) {
278+
TEST(HyperLogLogTest, DISABLED_PrestoCase2) {
280279
auto obj = HyperLogLogPresto<int64_t>(static_cast<uint64_t>(0));
281280
auto ans = obj.GetCardinality();
282281

@@ -289,15 +288,15 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoCase2) {
289288
ASSERT_EQ(obj.GetOverflowBucketofIndex(0).to_ullong(), 4);
290289
}
291290

292-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoEdgeCase) {
291+
TEST(HyperLogLogTest, DISABLED_PrestoEdgeCase) {
293292
auto obj = HyperLogLogPresto<int64_t>(-2);
294293
obj.ComputeCardinality();
295294
auto ans = obj.GetCardinality();
296295

297296
ASSERT_EQ(ans, 0);
298297
}
299298

300-
TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoEdgeCase2) {
299+
TEST(HyperLogLogTest, DISABLED_PrestoEdgeCase2) {
301300
auto obj = HyperLogLogPresto<int64_t>(0);
302301
obj.ComputeCardinality();
303302
auto ans = obj.GetCardinality();

0 commit comments

Comments
 (0)