Erase_at_pointer and related test#1161
Conversation
…g#1138 Resolve the parent JSON Pointer by splitting the full pointer into a parent prefix and last segment (via next_segment), then navigate to the parent with find_pointer instead of duplicating the walk_pointer logic.
|
An automated preview of the documentation is available at https://1161.json.prtest2.cppalliance.org/libs/json/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-05-10 21:37:43 UTC |
|
GCOVR code coverage report https://1161.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-05-10 21:49:17 UTC |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1161 +/- ##
===========================================
- Coverage 93.91% 93.86% -0.05%
===========================================
Files 91 91
Lines 9262 9306 +44
===========================================
+ Hits 8698 8735 +37
- Misses 564 571 +7
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
|
| value* parent = detail::walk_pointer( | ||
| *this, | ||
| parent_sv, |
There was a problem hiding this comment.
Wouldn't it make more sense to just walk the entire pointer string and in object and array handlers update a value* parent variable (in the case of object you'd have to also store the key)? Then, after you finished walking:
parentis a pointer toarray,objectornullptr(you can rely on that later in the switch case).- You don't have to check for missing slash manually.
- You don't have to walk the pointer string twice.
- You don't have to do manually look up the pointed-to element in the parent.
| []( array& arr, std::size_t index, system::error_code& ec ) -> value* | ||
| { | ||
| if( ec ) | ||
| return nullptr; |
There was a problem hiding this comment.
This is not covered by tests. See here: https://1161.json.prtest2.cppalliance.org/diff-report/include/boost/json/impl/pointer.ipp.html. There are also other lines that miss coverage.
| } | ||
| return false; | ||
| } | ||
| default: { |
There was a problem hiding this comment.
https://1161.json.prtest2.cppalliance.org/diff-report/include/boost/json/impl/pointer.ipp.html#NL593
I am pretty sure this switch case is unreachable, so replace it with
default: // LCOV_EXCL_LINE
BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE

based on the suggestion in #1138
Splits the JSON Pointer via next_segment, then navigate to the parent with find_pointer, this avoid duplicating the walk_pointer logic.