Add direct coverage for serialization helpers and tree boundaries#32
Conversation
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/cd6a239e-ca77-480e-b515-6c171a869977 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/cd6a239e-ca77-480e-b515-6c171a869977 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/cd6a239e-ca77-480e-b515-6c171a869977 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/cd6a239e-ca77-480e-b515-6c171a869977 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/cd6a239e-ca77-480e-b515-6c171a869977 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/cd6a239e-ca77-480e-b515-6c171a869977 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a dedicated “coverage” test binary to exercise low-level serialization helpers and boundary behaviors, while tightening PathT equality semantics and centralizing validation for partial tree serialization ranges.
Changes:
- Add
test/coverage.cppto directly cover serialization helpers,PathTmetadata/deserialization/equality, partial-serialization boundary cases, andTreeTmove/self-assignment. - Update
PathTequality to include leaf/max-index metadata and makeoperator!=const. - Centralize partial range validation for
TreeT::serialise(from,to)andTreeT::serialised_size(from,to), including explicit empty-tree rejection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/coverage.cpp | New targeted coverage test executable covering helper functions and boundary/error paths. |
| test/CMakeLists.txt | Registers the new coverage test target with the existing test harness. |
| merklecpp.h | Refines PathT equality/inequality semantics and factors partial-range validation into a shared helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot look at the compiler errors and fix them |
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/fe3cc83e-0fd8-4966-880a-f5bbe2208438 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/merklecpp/sessions/fe3cc83e-0fd8-4966-880a-f5bbe2208438 Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Fixed. I investigated the CI logs, resolved the compiler/clippy-style errors in |
| } | ||
| catch (const std::exception& ex) | ||
| { | ||
| std::cout << "Error: " << ex.what() << '\n'; |
There was a problem hiding this comment.
I think it's better to flush with std::endl to make sure we do not lose anything?
There was a problem hiding this comment.
I don't think we lose anything, the flushing may be a bit delayed, that's all. But this should arguably go to stderr, which is line buffered anyway.
| const bool from_out_of_range = from < min_index() || max_index() < from; | ||
| const bool to_out_of_range = to < min_index() || max_index() < to; | ||
| const bool reversed_range = from > to; | ||
| if (empty() || from_out_of_range || to_out_of_range || reversed_range) |
There was a problem hiding this comment.
Nit. 3 comparisons are enough
min() <= from && from <= to && to <= max()
| delete (n); | ||
| } | ||
| uninserted_leaf_nodes.clear(); | ||
| insertion_stack.clear(); |
There was a problem hiding this comment.
Just curious why .clear() and only then = move()?
There was a problem hiding this comment.
Also this's a dup of what we do in move ctor, so could've been made a single function, as in "clear()"
Uh oh!
There was an error while loading. Please reload this page.