2016-08-04 19:55:47 +00:00
|
|
|
/*
|
|
|
|
__ _____ _____ _____
|
|
|
|
__| | __| | | | JSON for Modern C++ (test suite)
|
2018-02-12 21:59:36 +00:00
|
|
|
| | |__ | | | | | | version 3.1.1
|
2016-08-04 19:55:47 +00:00
|
|
|
|_____|_____|_____|_|___| https://github.com/nlohmann/json
|
|
|
|
|
|
|
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
2018-02-01 21:20:26 +00:00
|
|
|
Copyright (c) 2013-2018 Niels Lohmann <http://nlohmann.me>.
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "catch.hpp"
|
|
|
|
|
2018-01-29 10:21:11 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2016-08-04 19:55:47 +00:00
|
|
|
using nlohmann::json;
|
|
|
|
|
|
|
|
TEST_CASE("capacity")
|
|
|
|
{
|
|
|
|
SECTION("empty()")
|
|
|
|
{
|
|
|
|
SECTION("boolean")
|
|
|
|
{
|
|
|
|
json j = true;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("string")
|
|
|
|
{
|
|
|
|
json j = "hello world";
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("array")
|
|
|
|
{
|
|
|
|
SECTION("empty array")
|
|
|
|
{
|
|
|
|
json j = json::array();
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == true);
|
|
|
|
CHECK(j_const.empty() == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("filled array")
|
|
|
|
{
|
|
|
|
json j = {1, 2, 3};
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("object")
|
|
|
|
{
|
|
|
|
SECTION("empty object")
|
|
|
|
{
|
|
|
|
json j = json::object();
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == true);
|
|
|
|
CHECK(j_const.empty() == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("filled object")
|
|
|
|
{
|
|
|
|
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (integer)")
|
|
|
|
{
|
2017-10-22 06:53:27 +00:00
|
|
|
json j = -23;
|
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (unsigned)")
|
|
|
|
{
|
|
|
|
json j = 23u;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (float)")
|
|
|
|
{
|
|
|
|
json j = 23.42;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == false);
|
|
|
|
CHECK(j_const.empty() == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("null")
|
|
|
|
{
|
|
|
|
json j = nullptr;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of empty")
|
|
|
|
{
|
|
|
|
CHECK(j.empty() == true);
|
|
|
|
CHECK(j_const.empty() == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of empty")
|
|
|
|
{
|
2016-08-04 20:04:55 +00:00
|
|
|
CHECK(j.empty() == (j.begin() == j.end()));
|
|
|
|
CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
|
2016-08-04 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("size()")
|
|
|
|
{
|
|
|
|
SECTION("boolean")
|
|
|
|
{
|
|
|
|
json j = true;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 1);
|
|
|
|
CHECK(j_const.size() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("string")
|
|
|
|
{
|
|
|
|
json j = "hello world";
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 1);
|
|
|
|
CHECK(j_const.size() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("array")
|
|
|
|
{
|
|
|
|
SECTION("empty array")
|
|
|
|
{
|
|
|
|
json j = json::array();
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 0);
|
|
|
|
CHECK(j_const.size() == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("filled array")
|
|
|
|
{
|
|
|
|
json j = {1, 2, 3};
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 3);
|
|
|
|
CHECK(j_const.size() == 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("object")
|
|
|
|
{
|
|
|
|
SECTION("empty object")
|
|
|
|
{
|
|
|
|
json j = json::object();
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 0);
|
|
|
|
CHECK(j_const.size() == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("filled object")
|
|
|
|
{
|
|
|
|
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 3);
|
|
|
|
CHECK(j_const.size() == 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (integer)")
|
|
|
|
{
|
2017-10-22 06:53:27 +00:00
|
|
|
json j = -23;
|
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 1);
|
|
|
|
CHECK(j_const.size() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (unsigned)")
|
|
|
|
{
|
|
|
|
json j = 23u;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 1);
|
|
|
|
CHECK(j_const.size() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (float)")
|
|
|
|
{
|
|
|
|
json j = 23.42;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 1);
|
|
|
|
CHECK(j_const.size() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("null")
|
|
|
|
{
|
|
|
|
json j = nullptr;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of size")
|
|
|
|
{
|
|
|
|
CHECK(j.size() == 0);
|
|
|
|
CHECK(j_const.size() == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("definition of size")
|
|
|
|
{
|
|
|
|
CHECK(std::distance(j.begin(), j.end()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size());
|
|
|
|
CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
|
|
|
|
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("max_size()")
|
|
|
|
{
|
|
|
|
SECTION("boolean")
|
|
|
|
{
|
|
|
|
json j = true;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() == 1);
|
|
|
|
CHECK(j_const.max_size() == 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("string")
|
|
|
|
{
|
|
|
|
json j = "hello world";
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() == 1);
|
|
|
|
CHECK(j_const.max_size() == 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("array")
|
|
|
|
{
|
|
|
|
SECTION("empty array")
|
|
|
|
{
|
|
|
|
json j = json::array();
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() >= j.size());
|
|
|
|
CHECK(j_const.max_size() >= j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("filled array")
|
|
|
|
{
|
|
|
|
json j = {1, 2, 3};
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() >= j.size());
|
|
|
|
CHECK(j_const.max_size() >= j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("object")
|
|
|
|
{
|
|
|
|
SECTION("empty object")
|
|
|
|
{
|
|
|
|
json j = json::object();
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() >= j.size());
|
|
|
|
CHECK(j_const.max_size() >= j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("filled object")
|
|
|
|
{
|
|
|
|
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() >= j.size());
|
|
|
|
CHECK(j_const.max_size() >= j_const.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (integer)")
|
|
|
|
{
|
2017-10-22 06:53:27 +00:00
|
|
|
json j = -23;
|
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() == 1);
|
|
|
|
CHECK(j_const.max_size() == 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (unsigned)")
|
|
|
|
{
|
|
|
|
json j = 23u;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() == 1);
|
|
|
|
CHECK(j_const.max_size() == 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("number (float)")
|
|
|
|
{
|
|
|
|
json j = 23.42;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() == 1);
|
|
|
|
CHECK(j_const.max_size() == 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("null")
|
|
|
|
{
|
|
|
|
json j = nullptr;
|
2017-10-22 06:53:27 +00:00
|
|
|
const json j_const(j);
|
2016-08-04 19:55:47 +00:00
|
|
|
|
|
|
|
SECTION("result of max_size")
|
|
|
|
{
|
|
|
|
CHECK(j.max_size() == 0);
|
|
|
|
CHECK(j_const.max_size() == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|