1c5f01b2fSopenharmony_ci//     __ _____ _____ _____
2c5f01b2fSopenharmony_ci//  __|  |   __|     |   | |  JSON for Modern C++ (supporting code)
3c5f01b2fSopenharmony_ci// |  |  |__   |  |  | | | |  version 3.11.2
4c5f01b2fSopenharmony_ci// |_____|_____|_____|_|___|  https://github.com/nlohmann/json
5c5f01b2fSopenharmony_ci//
6c5f01b2fSopenharmony_ci// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7c5f01b2fSopenharmony_ci// SPDX-License-Identifier: MIT
8c5f01b2fSopenharmony_ci
9c5f01b2fSopenharmony_ci#include "doctest_compatibility.h"
10c5f01b2fSopenharmony_ci
11c5f01b2fSopenharmony_ci#include <nlohmann/json.hpp>
12c5f01b2fSopenharmony_ciusing nlohmann::json;
13c5f01b2fSopenharmony_ci
14c5f01b2fSopenharmony_ci#include <algorithm>
15c5f01b2fSopenharmony_ci
16c5f01b2fSopenharmony_ciTEST_CASE("tests on very large JSONs")
17c5f01b2fSopenharmony_ci{
18c5f01b2fSopenharmony_ci    SECTION("issue #1419 - Segmentation fault (stack overflow) due to unbounded recursion")
19c5f01b2fSopenharmony_ci    {
20c5f01b2fSopenharmony_ci        const auto depth = 5000000;
21c5f01b2fSopenharmony_ci
22c5f01b2fSopenharmony_ci        std::string s(static_cast<std::size_t>(2 * depth), '[');
23c5f01b2fSopenharmony_ci        std::fill(s.begin() + depth, s.end(), ']');
24c5f01b2fSopenharmony_ci
25c5f01b2fSopenharmony_ci        json _;
26c5f01b2fSopenharmony_ci        CHECK_NOTHROW(_ = nlohmann::json::parse(s));
27c5f01b2fSopenharmony_ci    }
28c5f01b2fSopenharmony_ci}
29c5f01b2fSopenharmony_ci
30