Test output improvements.

This commit is contained in:
Steve Atherton 2021-04-22 14:55:28 -07:00
parent 9ab69b5cb1
commit b0ec76d401
2 changed files with 17 additions and 7 deletions

View File

@ -994,7 +994,10 @@ struct DeltaTree2 {
public:
struct DecodeCache : FastAllocated<DecodeCache> {
DecodeCache(const T& lowerBound = T(), const T& upperBound = T())
: lowerBound(arena, lowerBound), upperBound(arena, upperBound) {}
: lowerBound(arena, lowerBound), upperBound(arena, upperBound) {
partials.reserve(10);
printf("size: %d\n", sizeof(OffsetPartial));
}
Arena arena;
T lowerBound;

View File

@ -7139,9 +7139,7 @@ struct IntIntPair {
IntIntPair apply(const Partial& cache) { return cache; }
IntIntPair apply(Arena& arena, const IntIntPair& base, Optional<Partial>& cache) {
if (!cache.present()) {
cache = IntIntPair(base.k + dk, base.v + dv);
}
cache = IntIntPair(base.k + dk, base.v + dv);
return cache.get();
}
@ -7802,7 +7800,7 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") {
auto printItems = [&] {
for (int k = 0; k < items.size(); ++k) {
printf("%d/%d %s\n", k + 1, items.size(), items[k].toString().c_str());
debug_printf("%d/%d %s\n", k + 1, items.size(), items[k].toString().c_str());
}
};
@ -7812,14 +7810,14 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") {
(int)tree->size(),
(int)tree->initialHeight,
(int)tree->maxHeight);
debug_printf_always("Data(%p): %s\n", tree, StringRef((uint8_t*)tree, tree->size()).toHexString().c_str());
debug_printf("Data(%p): %s\n", tree, StringRef((uint8_t*)tree, tree->size()).toHexString().c_str());
printf("DeltaTree2: Count=%d Size=%d InitialHeight=%d MaxHeight=%d\n",
(int)tree2->numItems,
(int)tree2->size(),
(int)tree2->initialHeight,
(int)tree2->maxHeight);
debug_printf_always("Data(%p): %s\n", tree2, StringRef((uint8_t*)tree2, tree2->size()).toHexString().c_str());
debug_printf("Data(%p): %s\n", tree2, StringRef((uint8_t*)tree2, tree2->size()).toHexString().c_str());
};
// Iterate through items and tree forward and backward, verifying tree contents.
@ -7940,6 +7938,9 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") {
// Update items vector
items = std::vector<IntIntPair>(uniqueItems.begin(), uniqueItems.end());
printItems();
printTrees();
// Verify tree contents
scanAndVerify();
scanAndVerify2();
@ -7965,6 +7966,9 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") {
// Update items vector
items = std::vector<IntIntPair>(uniqueItems.begin(), uniqueItems.end());
printItems();
printTrees();
// Verify tree contents after deletions
scanAndVerify();
scanAndVerify2();
@ -7993,6 +7997,9 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") {
ASSERT(!cur2.insert(p));
}
printItems();
printTrees();
// Tree contents should still match items vector
scanAndVerify();
scanAndVerify2();