test(json): drop redundant iterator_traits test

The isValidJson2 call site in RPCCall.cpp already forces instantiation
of std::all_of over json::ValueConstIterator, so a regression that
removed the iterator traits would fail the real build. A dedicated
static_assert test is redundant; remove it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-07-24 15:23:50 +01:00
parent 5086c607e8
commit 1e50cadefe

View File

@@ -11,14 +11,12 @@
#include <cstdint>
#include <cstring>
#include <exception>
#include <iterator>
#include <limits>
#include <numbers>
#include <optional>
#include <regex>
#include <sstream>
#include <string>
#include <type_traits>
#include <utility>
namespace xrpl {
@@ -1333,44 +1331,6 @@ TEST(json_value, iterator)
}
}
TEST(json_value, iterator_traits)
{
// The iterators must expose value_type and iterator_category so that
// std::iterator_traits classifies them as (at least) input iterators.
// Without these, iterator_traits deduces output_iterator_tag and standard
// algorithms such as std::all_of fail to instantiate.
using CIt = json::ValueConstIterator;
using It = json::ValueIterator;
static_assert(std::is_same_v<std::iterator_traits<CIt>::value_type, json::Value>);
static_assert(std::is_same_v<std::iterator_traits<It>::value_type, json::Value>);
static_assert(std::is_same_v<
std::iterator_traits<CIt>::iterator_category,
std::bidirectional_iterator_tag>);
static_assert(std::is_same_v<
std::iterator_traits<It>::iterator_category,
std::bidirectional_iterator_tag>);
// A standard algorithm over the iterators must compile and run. This is the
// exact usage (std::all_of over a Value's members) that regressed the build.
json::Value obj{json::ValueType::Object};
obj["a"] = 2;
obj["b"] = 4;
obj["c"] = 6;
json::Value const& cobj = obj;
EXPECT_TRUE(std::all_of(cobj.begin(), cobj.end(), [](json::Value const& v) {
return v.asInt() % 2 == 0;
}));
EXPECT_FALSE(
std::all_of(cobj.begin(), cobj.end(), [](json::Value const& v) { return v.asInt() > 3; }));
// count_if exercises the input-iterator contract and returns an exact count.
EXPECT_EQ(
std::count_if(cobj.begin(), cobj.end(), [](json::Value const& v) { return v.asInt() > 3; }),
2);
}
TEST(json_value, nest_limits)
{
json::Reader r;