test: Add UniValue failed read test

Just to document the current behavior, fixed in the next commit.
This commit is contained in:
MarcoFalke
2026-08-26 09:30:34 +02:00
parent 031175197f
commit fa7786592d

View File

@@ -452,6 +452,16 @@ void univalue_readwrite()
BOOST_CHECK(!v.read("[]{}"));
BOOST_CHECK(!v.read("{}[]"));
BOOST_CHECK(!v.read("{} 42"));
// Failed read clears value
{
UniValue val{"previous value"};
BOOST_CHECK(!val.read(R"({"key":)"));
// This should be null (XXX, TODO, FIXME):
BOOST_CHECK(val.isObject());
BOOST_CHECK_EQUAL(val.getKeys().size(), 1);
BOOST_CHECK_EQUAL(val.getValues().size(), 0);
}
}
int main(int argc, char* argv[])