Skip to content

Commit

Permalink
fix other unit test failures for ci_test_diagnotic_positions
Browse files Browse the repository at this point in the history
Signed-off-by: Harinath Nampally <[email protected]>
  • Loading branch information
hnampally committed Jan 6, 2025
1 parent 777bae3 commit fab4d58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions include/nlohmann/detail/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,19 @@ class exception : public std::exception
return concat(a, '/', detail::escape(b));
});
#if JSON_DIAGNOSTIC_POSITIONS
str += ((leaf_element->start_pos() == std::string::npos) || (leaf_element->end_pos() == std::string::npos)) ? "" :
'(' + "byte " + std::to_string(leaf_element->start_pos()) + "-" + std::to_string(leaf_element->end_pos()) + ')';
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
{
str += ", byte " + std::to_string(leaf_element->start_pos()) + "-" + std::to_string(leaf_element->end_pos());
return concat('(', str, ") ");
}
#endif
return str;
#elif JSON_DIAGNOSTIC_POSITIONS
auto str = ((leaf_element->start_pos() == std::string::npos) || (leaf_element->end_pos() == std::string::npos)) ? "" :
'(' + "byte " + std::to_string(leaf_element->start_pos()) + "-" + std::to_string(leaf_element->end_pos()) + ')';
return str;
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
{
auto str = concat("byte ", std::to_string(leaf_element->start_pos()), "-", std::to_string(leaf_element->end_pos()));
return concat('(', str, ") ");
}
return "";
#else
static_cast<void>(leaf_element);
return "";
Expand Down
17 changes: 11 additions & 6 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4534,14 +4534,19 @@ class exception : public std::exception
return concat(a, '/', detail::escape(b));
});
#if JSON_DIAGNOSTIC_POSITIONS
str += ((leaf_element->start_pos() == std::string::npos) || (leaf_element->end_pos() == std::string::npos)) ? "" :
'(' + "byte " + std::to_string(leaf_element->start_pos()) + "-" + std::to_string(leaf_element->end_pos()) + ')';
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
{
str += ", byte " + std::to_string(leaf_element->start_pos()) + "-" + std::to_string(leaf_element->end_pos());
return concat('(', str, ") ");
}
#endif
return str;
#elif JSON_DIAGNOSTIC_POSITIONS
auto str = ((leaf_element->start_pos() == std::string::npos) || (leaf_element->end_pos() == std::string::npos)) ? "" :
'(' + "byte " + std::to_string(leaf_element->start_pos()) + "-" + std::to_string(leaf_element->end_pos()) + ')';
return str;
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
{
auto str = concat("byte ", std::to_string(leaf_element->start_pos()), "-", std::to_string(leaf_element->end_pos()));
return concat('(', str, ") ");
}
return "";
#else
static_cast<void>(leaf_element);
return "";
Expand Down

0 comments on commit fab4d58

Please sign in to comment.