a more forgiving array behavior
This commit is contained in:
parent
1cd256a95e
commit
bc2e3a798d
4 changed files with 48 additions and 10 deletions
|
@ -2033,10 +2033,20 @@ TEST_CASE("element access")
|
|||
{
|
||||
SECTION("null")
|
||||
{
|
||||
json j_nonarray(json::value_t::null);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
CHECK_THROWS_AS(j_nonarray[0], std::runtime_error);
|
||||
CHECK_THROWS_AS(j_nonarray_const[0], std::runtime_error);
|
||||
SECTION("standard tests")
|
||||
{
|
||||
json j_nonarray(json::value_t::null);
|
||||
const json j_nonarray_const(j_nonarray);
|
||||
CHECK_NOTHROW(j_nonarray[0]);
|
||||
CHECK_THROWS_AS(j_nonarray_const[0], std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("implicit transformation to properly filled array")
|
||||
{
|
||||
json j_nonarray;
|
||||
j_nonarray[3] = 42;
|
||||
CHECK(j_nonarray == json({nullptr, nullptr, nullptr, 42}));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("boolean")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue