Skip to content

Conversation

@RoyBellingan
Copy link

Hopefully a more clear and decent version of #1071

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://1138.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-01-06 06:22:58 UTC

@cppalliance-bot
Copy link

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 82.81250% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.59%. Comparing base (6238e35) to head (4c97cd0).

Files with missing lines Patch % Lines
include/boost/json/impl/pointer.ipp 82.81% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1138      +/-   ##
===========================================
- Coverage    93.67%   93.59%   -0.08%     
===========================================
  Files           91       91              
  Lines         9153     9217      +64     
===========================================
+ Hits          8574     8627      +53     
- Misses         579      590      +11     
Files with missing lines Coverage Δ
include/boost/json/value.hpp 98.83% <ø> (ø)
include/boost/json/impl/pointer.ipp 96.41% <82.81%> (-3.59%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6238e35...4c97cd0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot
Copy link

Copy link
Member

@grisumbras grisumbras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to other changes, I expect the tests to have the full code coverage of the added lines.

{
ec.clear();
if(sv.empty()){
BOOST_JSON_FAIL(ec, error::syntax);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error::syntax is for JSON syntax errors. Arguably, error::missing_slash is fitting (you require at least one pointer token, and a pointer token starts with a /. But there's an interesting question if we want to allow zero tokens, and what to do in that case. For example, we can set the root object to null.

doc_uses_allocator.cpp
doc_using_numbers.cpp
double.cpp
erase_at_pointer.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this feature warrants a separate test file. Just use pointer.cpp.

*/
BOOST_JSON_DECL
bool
erase_at_pointer(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be a non-throwing overload.

result = arr.if_contains(index);
if( !result )
{
BOOST_JSON_FAIL(ec, error::past_the_end);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error::past_the_end is for when the current token is the past-the-end token (-). This is just error::not_found.

#include <boost/json/parse.hpp>
#include <boost/json/serialize.hpp>
#include "test_suite.hpp"
#include <iostream>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is not used.

value json = testValueArray();

value target = boost::json::parse(R"(
[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, here and elsewhere indent according to the surrounding code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥲

)";
return boost::json::parse(raw);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you configure your editor/IDE to not have stray whitespace at the end of lines?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞


bool
value::erase_at_pointer(
string_view sv,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, reformat here and elsewhere. The project doesn't do such token alignment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😓

auto result = this;
auto previous_result = this;

while (true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this loop, this is pretty much walk_pointer used with find_pointer lambdas, followed by element erasure, if the search was successful. The only difference is that you need to store the parent of the discovered element, which can be achieved with lambdas with captures.

So, why not do that instead of duplicating walk_pointer?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check that part of the code, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants