Skip to content

Commit 7d3f7df

Browse files
Merge pull request #437 from apache/minor_cleanup
minor cleanup
2 parents a8348c2 + 5a334d4 commit 7d3f7df

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

kll/test/kll_sketch_custom_type_test.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ using alloc = test_allocator<test_type>;
3131

3232
TEST_CASE("kll sketch custom type", "[kll_sketch]") {
3333

34-
// setup section
3534
test_allocator_total_bytes = 0;
35+
test_allocator_net_allocations = 0;
3636

3737
SECTION("compact level zero") {
3838
kll_test_type_sketch sketch(8, test_type_less(), 0);
39+
REQUIRE(test_allocator_total_bytes != 0);
40+
REQUIRE(test_allocator_net_allocations != 0);
41+
3942
REQUIRE_THROWS_AS(sketch.get_quantile(0), std::runtime_error);
4043
REQUIRE_THROWS_AS(sketch.get_min_item(), std::runtime_error);
4144
REQUIRE_THROWS_AS(sketch.get_max_item(), std::runtime_error);
@@ -146,10 +149,8 @@ TEST_CASE("kll sketch custom type", "[kll_sketch]") {
146149
REQUIRE(sketch2.get_n() == 11);
147150
}
148151

149-
// cleanup
150-
if (test_allocator_total_bytes != 0) {
151-
REQUIRE(test_allocator_total_bytes == 0);
152-
}
152+
REQUIRE(test_allocator_total_bytes == 0);
153+
REQUIRE(test_allocator_net_allocations == 0);
153154
}
154155

155156
} /* namespace datasketches */

theta/test/bit_packing_test.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,30 @@ static const uint64_t IGOLDEN64 = 0x9e3779b97f4a7c13ULL;
3030

3131
TEST_CASE("pack unpack bits") {
3232
for (uint8_t bits = 1; bits <= 63; ++bits) {
33+
int n = 8;
3334
const uint64_t mask = (1ULL << bits) - 1;
34-
std::vector<uint64_t> input(8, 0);
35+
std::vector<uint64_t> input(n, 0);
3536
const uint64_t igolden64 = IGOLDEN64;
3637
uint64_t value = 0xaa55aa55aa55aa55ULL; // arbitrary starting value
37-
for (int i = 0; i < 8; ++i) {
38+
for (int i = 0; i < n; ++i) {
3839
input[i] = value & mask;
3940
value += igolden64;
4041
}
41-
std::vector<uint8_t> bytes(8 * sizeof(uint64_t), 0);
42+
std::vector<uint8_t> bytes(n * sizeof(uint64_t), 0);
4243
uint8_t offset = 0;
4344
uint8_t* ptr = bytes.data();
44-
for (int i = 0; i < 8; ++i) {
45+
for (int i = 0; i < n; ++i) {
4546
offset = pack_bits(input[i], bits, ptr, offset);
4647
}
4748

48-
std::vector<uint64_t> output(8, 0);
49+
std::vector<uint64_t> output(n, 0);
4950
offset = 0;
5051
const uint8_t* cptr = bytes.data();
51-
for (int i = 0; i < 8; ++i) {
52+
for (int i = 0; i < n; ++i) {
5253
offset = unpack_bits(output[i], bits, cptr, offset);
5354
}
54-
for (int i = 0; i < 8; ++i) {
55-
REQUIRE((input[i] & mask) == output[i]);
55+
for (int i = 0; i < n; ++i) {
56+
REQUIRE(input[i] == output[i]);
5657
}
5758
}
5859
}

0 commit comments

Comments
 (0)