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 <sstream>
15c5f01b2fSopenharmony_ci#include <iomanip>
16c5f01b2fSopenharmony_ci
17c5f01b2fSopenharmony_ciTEST_CASE("serialization")
18c5f01b2fSopenharmony_ci{
19c5f01b2fSopenharmony_ci    SECTION("operator<<")
20c5f01b2fSopenharmony_ci    {
21c5f01b2fSopenharmony_ci        SECTION("no given width")
22c5f01b2fSopenharmony_ci        {
23c5f01b2fSopenharmony_ci            std::stringstream ss;
24c5f01b2fSopenharmony_ci            json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
25c5f01b2fSopenharmony_ci            ss << j;
26c5f01b2fSopenharmony_ci            CHECK(ss.str() == "[\"foo\",1,2,3,false,{\"one\":1}]");
27c5f01b2fSopenharmony_ci        }
28c5f01b2fSopenharmony_ci
29c5f01b2fSopenharmony_ci        SECTION("given width")
30c5f01b2fSopenharmony_ci        {
31c5f01b2fSopenharmony_ci            std::stringstream ss;
32c5f01b2fSopenharmony_ci            json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
33c5f01b2fSopenharmony_ci            ss << std::setw(4) << j;
34c5f01b2fSopenharmony_ci            CHECK(ss.str() ==
35c5f01b2fSopenharmony_ci                  "[\n    \"foo\",\n    1,\n    2,\n    3,\n    false,\n    {\n        \"one\": 1\n    }\n]");
36c5f01b2fSopenharmony_ci        }
37c5f01b2fSopenharmony_ci
38c5f01b2fSopenharmony_ci        SECTION("given fill")
39c5f01b2fSopenharmony_ci        {
40c5f01b2fSopenharmony_ci            std::stringstream ss;
41c5f01b2fSopenharmony_ci            json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
42c5f01b2fSopenharmony_ci            ss << std::setw(1) << std::setfill('\t') << j;
43c5f01b2fSopenharmony_ci            CHECK(ss.str() ==
44c5f01b2fSopenharmony_ci                  "[\n\t\"foo\",\n\t1,\n\t2,\n\t3,\n\tfalse,\n\t{\n\t\t\"one\": 1\n\t}\n]");
45c5f01b2fSopenharmony_ci        }
46c5f01b2fSopenharmony_ci    }
47c5f01b2fSopenharmony_ci
48c5f01b2fSopenharmony_ci    SECTION("operator>>")
49c5f01b2fSopenharmony_ci    {
50c5f01b2fSopenharmony_ci        SECTION("no given width")
51c5f01b2fSopenharmony_ci        {
52c5f01b2fSopenharmony_ci            std::stringstream ss;
53c5f01b2fSopenharmony_ci            json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
54c5f01b2fSopenharmony_ci            j >> ss;
55c5f01b2fSopenharmony_ci            CHECK(ss.str() == "[\"foo\",1,2,3,false,{\"one\":1}]");
56c5f01b2fSopenharmony_ci        }
57c5f01b2fSopenharmony_ci
58c5f01b2fSopenharmony_ci        SECTION("given width")
59c5f01b2fSopenharmony_ci        {
60c5f01b2fSopenharmony_ci            std::stringstream ss;
61c5f01b2fSopenharmony_ci            json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
62c5f01b2fSopenharmony_ci            ss.width(4);
63c5f01b2fSopenharmony_ci            j >> ss;
64c5f01b2fSopenharmony_ci            CHECK(ss.str() ==
65c5f01b2fSopenharmony_ci                  "[\n    \"foo\",\n    1,\n    2,\n    3,\n    false,\n    {\n        \"one\": 1\n    }\n]");
66c5f01b2fSopenharmony_ci        }
67c5f01b2fSopenharmony_ci
68c5f01b2fSopenharmony_ci        SECTION("given fill")
69c5f01b2fSopenharmony_ci        {
70c5f01b2fSopenharmony_ci            std::stringstream ss;
71c5f01b2fSopenharmony_ci            json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
72c5f01b2fSopenharmony_ci            ss.width(1);
73c5f01b2fSopenharmony_ci            ss.fill('\t');
74c5f01b2fSopenharmony_ci            j >> ss;
75c5f01b2fSopenharmony_ci            CHECK(ss.str() ==
76c5f01b2fSopenharmony_ci                  "[\n\t\"foo\",\n\t1,\n\t2,\n\t3,\n\tfalse,\n\t{\n\t\t\"one\": 1\n\t}\n]");
77c5f01b2fSopenharmony_ci        }
78c5f01b2fSopenharmony_ci    }
79c5f01b2fSopenharmony_ci
80c5f01b2fSopenharmony_ci    SECTION("dump")
81c5f01b2fSopenharmony_ci    {
82c5f01b2fSopenharmony_ci        SECTION("invalid character")
83c5f01b2fSopenharmony_ci        {
84c5f01b2fSopenharmony_ci            json j = "ä\xA9ü";
85c5f01b2fSopenharmony_ci
86c5f01b2fSopenharmony_ci            CHECK_THROWS_WITH_AS(j.dump(), "[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9", json::type_error&);
87c5f01b2fSopenharmony_ci            CHECK_THROWS_WITH_AS(j.dump(1, ' ', false, json::error_handler_t::strict), "[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9", json::type_error&);
88c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', false, json::error_handler_t::ignore) == "\"äü\"");
89c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', false, json::error_handler_t::replace) == "\"ä\xEF\xBF\xBDü\"");
90c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', true, json::error_handler_t::replace) == "\"\\u00e4\\ufffd\\u00fc\"");
91c5f01b2fSopenharmony_ci        }
92c5f01b2fSopenharmony_ci
93c5f01b2fSopenharmony_ci        SECTION("ending with incomplete character")
94c5f01b2fSopenharmony_ci        {
95c5f01b2fSopenharmony_ci            json j = "123\xC2";
96c5f01b2fSopenharmony_ci
97c5f01b2fSopenharmony_ci            CHECK_THROWS_WITH_AS(j.dump(), "[json.exception.type_error.316] incomplete UTF-8 string; last byte: 0xC2", json::type_error&);
98c5f01b2fSopenharmony_ci            CHECK_THROWS_AS(j.dump(1, ' ', false, json::error_handler_t::strict), json::type_error&);
99c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', false, json::error_handler_t::ignore) == "\"123\"");
100c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', false, json::error_handler_t::replace) == "\"123\xEF\xBF\xBD\"");
101c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', true, json::error_handler_t::replace) == "\"123\\ufffd\"");
102c5f01b2fSopenharmony_ci        }
103c5f01b2fSopenharmony_ci
104c5f01b2fSopenharmony_ci        SECTION("unexpected character")
105c5f01b2fSopenharmony_ci        {
106c5f01b2fSopenharmony_ci            json j = "123\xF1\xB0\x34\x35\x36";
107c5f01b2fSopenharmony_ci
108c5f01b2fSopenharmony_ci            CHECK_THROWS_WITH_AS(j.dump(), "[json.exception.type_error.316] invalid UTF-8 byte at index 5: 0x34", json::type_error&);
109c5f01b2fSopenharmony_ci            CHECK_THROWS_AS(j.dump(1, ' ', false, json::error_handler_t::strict), json::type_error&);
110c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', false, json::error_handler_t::ignore) == "\"123456\"");
111c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', false, json::error_handler_t::replace) == "\"123\xEF\xBF\xBD\x34\x35\x36\"");
112c5f01b2fSopenharmony_ci            CHECK(j.dump(-1, ' ', true, json::error_handler_t::replace) == "\"123\\ufffd456\"");
113c5f01b2fSopenharmony_ci        }
114c5f01b2fSopenharmony_ci
115c5f01b2fSopenharmony_ci        SECTION("U+FFFD Substitution of Maximal Subparts")
116c5f01b2fSopenharmony_ci        {
117c5f01b2fSopenharmony_ci            // Some tests (mostly) from
118c5f01b2fSopenharmony_ci            // https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf
119c5f01b2fSopenharmony_ci            // Section 3.9 -- U+FFFD Substitution of Maximal Subparts
120c5f01b2fSopenharmony_ci
121c5f01b2fSopenharmony_ci            auto test = [&](std::string const & input, std::string const & expected)
122c5f01b2fSopenharmony_ci            {
123c5f01b2fSopenharmony_ci                json j = input;
124c5f01b2fSopenharmony_ci                CHECK(j.dump(-1, ' ', true, json::error_handler_t::replace) == "\"" + expected + "\"");
125c5f01b2fSopenharmony_ci            };
126c5f01b2fSopenharmony_ci
127c5f01b2fSopenharmony_ci            test("\xC2", "\\ufffd");
128c5f01b2fSopenharmony_ci            test("\xC2\x41\x42", "\\ufffd" "\x41" "\x42");
129c5f01b2fSopenharmony_ci            test("\xC2\xF4", "\\ufffd" "\\ufffd");
130c5f01b2fSopenharmony_ci
131c5f01b2fSopenharmony_ci            test("\xF0\x80\x80\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
132c5f01b2fSopenharmony_ci            test("\xF1\x80\x80\x41", "\\ufffd" "\x41");
133c5f01b2fSopenharmony_ci            test("\xF2\x80\x80\x41", "\\ufffd" "\x41");
134c5f01b2fSopenharmony_ci            test("\xF3\x80\x80\x41", "\\ufffd" "\x41");
135c5f01b2fSopenharmony_ci            test("\xF4\x80\x80\x41", "\\ufffd" "\x41");
136c5f01b2fSopenharmony_ci            test("\xF5\x80\x80\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
137c5f01b2fSopenharmony_ci
138c5f01b2fSopenharmony_ci            test("\xF0\x90\x80\x41", "\\ufffd" "\x41");
139c5f01b2fSopenharmony_ci            test("\xF1\x90\x80\x41", "\\ufffd" "\x41");
140c5f01b2fSopenharmony_ci            test("\xF2\x90\x80\x41", "\\ufffd" "\x41");
141c5f01b2fSopenharmony_ci            test("\xF3\x90\x80\x41", "\\ufffd" "\x41");
142c5f01b2fSopenharmony_ci            test("\xF4\x90\x80\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
143c5f01b2fSopenharmony_ci            test("\xF5\x90\x80\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
144c5f01b2fSopenharmony_ci
145c5f01b2fSopenharmony_ci            test("\xC0\xAF\xE0\x80\xBF\xF0\x81\x82\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
146c5f01b2fSopenharmony_ci            test("\xED\xA0\x80\xED\xBF\xBF\xED\xAF\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
147c5f01b2fSopenharmony_ci            test("\xF4\x91\x92\x93\xFF\x41\x80\xBF\x42", "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\x41" "\\ufffd""\\ufffd" "\x42");
148c5f01b2fSopenharmony_ci            test("\xE1\x80\xE2\xF0\x91\x92\xF1\xBF\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\x41");
149c5f01b2fSopenharmony_ci        }
150c5f01b2fSopenharmony_ci    }
151c5f01b2fSopenharmony_ci
152c5f01b2fSopenharmony_ci    SECTION("to_string")
153c5f01b2fSopenharmony_ci    {
154c5f01b2fSopenharmony_ci        auto test = [&](std::string const & input, std::string const & expected)
155c5f01b2fSopenharmony_ci        {
156c5f01b2fSopenharmony_ci            using std::to_string;
157c5f01b2fSopenharmony_ci            json j = input;
158c5f01b2fSopenharmony_ci            CHECK(to_string(j) == "\"" + expected + "\"");
159c5f01b2fSopenharmony_ci        };
160c5f01b2fSopenharmony_ci
161c5f01b2fSopenharmony_ci        test(R"({"x":5,"y":6})", R"({\"x\":5,\"y\":6})");
162c5f01b2fSopenharmony_ci        test("{\"x\":[10,null,null,null]}", R"({\"x\":[10,null,null,null]})");
163c5f01b2fSopenharmony_ci        test("test", "test");
164c5f01b2fSopenharmony_ci        test("[3,\"false\",false]", R"([3,\"false\",false])");
165c5f01b2fSopenharmony_ci    }
166c5f01b2fSopenharmony_ci}
167c5f01b2fSopenharmony_ci
168c5f01b2fSopenharmony_ciTEST_CASE_TEMPLATE("serialization for extreme integer values", T, int32_t, uint32_t, int64_t, uint64_t)
169c5f01b2fSopenharmony_ci{
170c5f01b2fSopenharmony_ci    SECTION("minimum")
171c5f01b2fSopenharmony_ci    {
172c5f01b2fSopenharmony_ci        constexpr auto minimum = (std::numeric_limits<T>::min)();
173c5f01b2fSopenharmony_ci        json j = minimum;
174c5f01b2fSopenharmony_ci        CHECK(j.dump() == std::to_string(minimum));
175c5f01b2fSopenharmony_ci    }
176c5f01b2fSopenharmony_ci
177c5f01b2fSopenharmony_ci    SECTION("maximum")
178c5f01b2fSopenharmony_ci    {
179c5f01b2fSopenharmony_ci        constexpr auto maximum = (std::numeric_limits<T>::max)();
180c5f01b2fSopenharmony_ci        json j = maximum;
181c5f01b2fSopenharmony_ci        CHECK(j.dump() == std::to_string(maximum));
182c5f01b2fSopenharmony_ci    }
183c5f01b2fSopenharmony_ci}
184c5f01b2fSopenharmony_ci
185c5f01b2fSopenharmony_ciTEST_CASE("dump with binary values")
186c5f01b2fSopenharmony_ci{
187c5f01b2fSopenharmony_ci    auto binary = json::binary({1, 2, 3, 4});
188c5f01b2fSopenharmony_ci    auto binary_empty = json::binary({});
189c5f01b2fSopenharmony_ci    auto binary_with_subtype = json::binary({1, 2, 3, 4}, 128);
190c5f01b2fSopenharmony_ci    auto binary_empty_with_subtype = json::binary({}, 128);
191c5f01b2fSopenharmony_ci
192c5f01b2fSopenharmony_ci    json object = {{"key", binary}};
193c5f01b2fSopenharmony_ci    json object_empty = {{"key", binary_empty}};
194c5f01b2fSopenharmony_ci    json object_with_subtype = {{"key", binary_with_subtype}};
195c5f01b2fSopenharmony_ci    json object_empty_with_subtype = {{"key", binary_empty_with_subtype}};
196c5f01b2fSopenharmony_ci
197c5f01b2fSopenharmony_ci    json array = {"value", 1, binary};
198c5f01b2fSopenharmony_ci    json array_empty = {"value", 1, binary_empty};
199c5f01b2fSopenharmony_ci    json array_with_subtype = {"value", 1, binary_with_subtype};
200c5f01b2fSopenharmony_ci    json array_empty_with_subtype = {"value", 1, binary_empty_with_subtype};
201c5f01b2fSopenharmony_ci
202c5f01b2fSopenharmony_ci    SECTION("normal")
203c5f01b2fSopenharmony_ci    {
204c5f01b2fSopenharmony_ci        CHECK(binary.dump() == "{\"bytes\":[1,2,3,4],\"subtype\":null}");
205c5f01b2fSopenharmony_ci        CHECK(binary_empty.dump() == "{\"bytes\":[],\"subtype\":null}");
206c5f01b2fSopenharmony_ci        CHECK(binary_with_subtype.dump() == "{\"bytes\":[1,2,3,4],\"subtype\":128}");
207c5f01b2fSopenharmony_ci        CHECK(binary_empty_with_subtype.dump() == "{\"bytes\":[],\"subtype\":128}");
208c5f01b2fSopenharmony_ci
209c5f01b2fSopenharmony_ci        CHECK(object.dump() == "{\"key\":{\"bytes\":[1,2,3,4],\"subtype\":null}}");
210c5f01b2fSopenharmony_ci        CHECK(object_empty.dump() == "{\"key\":{\"bytes\":[],\"subtype\":null}}");
211c5f01b2fSopenharmony_ci        CHECK(object_with_subtype.dump() == "{\"key\":{\"bytes\":[1,2,3,4],\"subtype\":128}}");
212c5f01b2fSopenharmony_ci        CHECK(object_empty_with_subtype.dump() == "{\"key\":{\"bytes\":[],\"subtype\":128}}");
213c5f01b2fSopenharmony_ci
214c5f01b2fSopenharmony_ci        CHECK(array.dump() == "[\"value\",1,{\"bytes\":[1,2,3,4],\"subtype\":null}]");
215c5f01b2fSopenharmony_ci        CHECK(array_empty.dump() == "[\"value\",1,{\"bytes\":[],\"subtype\":null}]");
216c5f01b2fSopenharmony_ci        CHECK(array_with_subtype.dump() == "[\"value\",1,{\"bytes\":[1,2,3,4],\"subtype\":128}]");
217c5f01b2fSopenharmony_ci        CHECK(array_empty_with_subtype.dump() == "[\"value\",1,{\"bytes\":[],\"subtype\":128}]");
218c5f01b2fSopenharmony_ci    }
219c5f01b2fSopenharmony_ci
220c5f01b2fSopenharmony_ci    SECTION("pretty-printed")
221c5f01b2fSopenharmony_ci    {
222c5f01b2fSopenharmony_ci        CHECK(binary.dump(4) == "{\n"
223c5f01b2fSopenharmony_ci              "    \"bytes\": [1, 2, 3, 4],\n"
224c5f01b2fSopenharmony_ci              "    \"subtype\": null\n"
225c5f01b2fSopenharmony_ci              "}");
226c5f01b2fSopenharmony_ci        CHECK(binary_empty.dump(4) == "{\n"
227c5f01b2fSopenharmony_ci              "    \"bytes\": [],\n"
228c5f01b2fSopenharmony_ci              "    \"subtype\": null\n"
229c5f01b2fSopenharmony_ci              "}");
230c5f01b2fSopenharmony_ci        CHECK(binary_with_subtype.dump(4) == "{\n"
231c5f01b2fSopenharmony_ci              "    \"bytes\": [1, 2, 3, 4],\n"
232c5f01b2fSopenharmony_ci              "    \"subtype\": 128\n"
233c5f01b2fSopenharmony_ci              "}");
234c5f01b2fSopenharmony_ci        CHECK(binary_empty_with_subtype.dump(4) == "{\n"
235c5f01b2fSopenharmony_ci              "    \"bytes\": [],\n"
236c5f01b2fSopenharmony_ci              "    \"subtype\": 128\n"
237c5f01b2fSopenharmony_ci              "}");
238c5f01b2fSopenharmony_ci
239c5f01b2fSopenharmony_ci        CHECK(object.dump(4) == "{\n"
240c5f01b2fSopenharmony_ci              "    \"key\": {\n"
241c5f01b2fSopenharmony_ci              "        \"bytes\": [1, 2, 3, 4],\n"
242c5f01b2fSopenharmony_ci              "        \"subtype\": null\n"
243c5f01b2fSopenharmony_ci              "    }\n"
244c5f01b2fSopenharmony_ci              "}");
245c5f01b2fSopenharmony_ci        CHECK(object_empty.dump(4) == "{\n"
246c5f01b2fSopenharmony_ci              "    \"key\": {\n"
247c5f01b2fSopenharmony_ci              "        \"bytes\": [],\n"
248c5f01b2fSopenharmony_ci              "        \"subtype\": null\n"
249c5f01b2fSopenharmony_ci              "    }\n"
250c5f01b2fSopenharmony_ci              "}");
251c5f01b2fSopenharmony_ci        CHECK(object_with_subtype.dump(4) == "{\n"
252c5f01b2fSopenharmony_ci              "    \"key\": {\n"
253c5f01b2fSopenharmony_ci              "        \"bytes\": [1, 2, 3, 4],\n"
254c5f01b2fSopenharmony_ci              "        \"subtype\": 128\n"
255c5f01b2fSopenharmony_ci              "    }\n"
256c5f01b2fSopenharmony_ci              "}");
257c5f01b2fSopenharmony_ci        CHECK(object_empty_with_subtype.dump(4) == "{\n"
258c5f01b2fSopenharmony_ci              "    \"key\": {\n"
259c5f01b2fSopenharmony_ci              "        \"bytes\": [],\n"
260c5f01b2fSopenharmony_ci              "        \"subtype\": 128\n"
261c5f01b2fSopenharmony_ci              "    }\n"
262c5f01b2fSopenharmony_ci              "}");
263c5f01b2fSopenharmony_ci
264c5f01b2fSopenharmony_ci        CHECK(array.dump(4) == "[\n"
265c5f01b2fSopenharmony_ci              "    \"value\",\n"
266c5f01b2fSopenharmony_ci              "    1,\n"
267c5f01b2fSopenharmony_ci              "    {\n"
268c5f01b2fSopenharmony_ci              "        \"bytes\": [1, 2, 3, 4],\n"
269c5f01b2fSopenharmony_ci              "        \"subtype\": null\n"
270c5f01b2fSopenharmony_ci              "    }\n"
271c5f01b2fSopenharmony_ci              "]");
272c5f01b2fSopenharmony_ci        CHECK(array_empty.dump(4) == "[\n"
273c5f01b2fSopenharmony_ci              "    \"value\",\n"
274c5f01b2fSopenharmony_ci              "    1,\n"
275c5f01b2fSopenharmony_ci              "    {\n"
276c5f01b2fSopenharmony_ci              "        \"bytes\": [],\n"
277c5f01b2fSopenharmony_ci              "        \"subtype\": null\n"
278c5f01b2fSopenharmony_ci              "    }\n"
279c5f01b2fSopenharmony_ci              "]");
280c5f01b2fSopenharmony_ci        CHECK(array_with_subtype.dump(4) == "[\n"
281c5f01b2fSopenharmony_ci              "    \"value\",\n"
282c5f01b2fSopenharmony_ci              "    1,\n"
283c5f01b2fSopenharmony_ci              "    {\n"
284c5f01b2fSopenharmony_ci              "        \"bytes\": [1, 2, 3, 4],\n"
285c5f01b2fSopenharmony_ci              "        \"subtype\": 128\n"
286c5f01b2fSopenharmony_ci              "    }\n"
287c5f01b2fSopenharmony_ci              "]");
288c5f01b2fSopenharmony_ci        CHECK(array_empty_with_subtype.dump(4) == "[\n"
289c5f01b2fSopenharmony_ci              "    \"value\",\n"
290c5f01b2fSopenharmony_ci              "    1,\n"
291c5f01b2fSopenharmony_ci              "    {\n"
292c5f01b2fSopenharmony_ci              "        \"bytes\": [],\n"
293c5f01b2fSopenharmony_ci              "        \"subtype\": 128\n"
294c5f01b2fSopenharmony_ci              "    }\n"
295c5f01b2fSopenharmony_ci              "]");
296c5f01b2fSopenharmony_ci    }
297c5f01b2fSopenharmony_ci}
298