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#define JSON_TESTS_PRIVATE
12c5f01b2fSopenharmony_ci#include <nlohmann/json.hpp>
13c5f01b2fSopenharmony_ciusing nlohmann::json;
14c5f01b2fSopenharmony_ci
15c5f01b2fSopenharmony_ciTEST_CASE("const_iterator class")
16c5f01b2fSopenharmony_ci{
17c5f01b2fSopenharmony_ci    SECTION("construction")
18c5f01b2fSopenharmony_ci    {
19c5f01b2fSopenharmony_ci        SECTION("constructor")
20c5f01b2fSopenharmony_ci        {
21c5f01b2fSopenharmony_ci            SECTION("null")
22c5f01b2fSopenharmony_ci            {
23c5f01b2fSopenharmony_ci                json j(json::value_t::null);
24c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
25c5f01b2fSopenharmony_ci            }
26c5f01b2fSopenharmony_ci
27c5f01b2fSopenharmony_ci            SECTION("object")
28c5f01b2fSopenharmony_ci            {
29c5f01b2fSopenharmony_ci                json j(json::value_t::object);
30c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
31c5f01b2fSopenharmony_ci            }
32c5f01b2fSopenharmony_ci
33c5f01b2fSopenharmony_ci            SECTION("array")
34c5f01b2fSopenharmony_ci            {
35c5f01b2fSopenharmony_ci                json j(json::value_t::array);
36c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
37c5f01b2fSopenharmony_ci            }
38c5f01b2fSopenharmony_ci        }
39c5f01b2fSopenharmony_ci
40c5f01b2fSopenharmony_ci        SECTION("copy assignment")
41c5f01b2fSopenharmony_ci        {
42c5f01b2fSopenharmony_ci            json j(json::value_t::null);
43c5f01b2fSopenharmony_ci            json::const_iterator it(&j);
44c5f01b2fSopenharmony_ci            json::const_iterator it2(&j);
45c5f01b2fSopenharmony_ci            it2 = it;
46c5f01b2fSopenharmony_ci        }
47c5f01b2fSopenharmony_ci
48c5f01b2fSopenharmony_ci        SECTION("copy constructor from non-const iterator")
49c5f01b2fSopenharmony_ci        {
50c5f01b2fSopenharmony_ci            SECTION("create from uninitialized iterator")
51c5f01b2fSopenharmony_ci            {
52c5f01b2fSopenharmony_ci                const json::iterator it {};
53c5f01b2fSopenharmony_ci                json::const_iterator cit(it);
54c5f01b2fSopenharmony_ci            }
55c5f01b2fSopenharmony_ci
56c5f01b2fSopenharmony_ci            SECTION("create from initialized iterator")
57c5f01b2fSopenharmony_ci            {
58c5f01b2fSopenharmony_ci                json j;
59c5f01b2fSopenharmony_ci                const json::iterator it = j.begin();
60c5f01b2fSopenharmony_ci                json::const_iterator cit(it);
61c5f01b2fSopenharmony_ci            }
62c5f01b2fSopenharmony_ci        }
63c5f01b2fSopenharmony_ci    }
64c5f01b2fSopenharmony_ci
65c5f01b2fSopenharmony_ci    SECTION("initialization")
66c5f01b2fSopenharmony_ci    {
67c5f01b2fSopenharmony_ci        SECTION("set_begin")
68c5f01b2fSopenharmony_ci        {
69c5f01b2fSopenharmony_ci            SECTION("null")
70c5f01b2fSopenharmony_ci            {
71c5f01b2fSopenharmony_ci                json j(json::value_t::null);
72c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
73c5f01b2fSopenharmony_ci                it.set_begin();
74c5f01b2fSopenharmony_ci                CHECK((it == j.cbegin()));
75c5f01b2fSopenharmony_ci            }
76c5f01b2fSopenharmony_ci
77c5f01b2fSopenharmony_ci            SECTION("object")
78c5f01b2fSopenharmony_ci            {
79c5f01b2fSopenharmony_ci                json j(json::value_t::object);
80c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
81c5f01b2fSopenharmony_ci                it.set_begin();
82c5f01b2fSopenharmony_ci                CHECK((it == j.cbegin()));
83c5f01b2fSopenharmony_ci            }
84c5f01b2fSopenharmony_ci
85c5f01b2fSopenharmony_ci            SECTION("array")
86c5f01b2fSopenharmony_ci            {
87c5f01b2fSopenharmony_ci                json j(json::value_t::array);
88c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
89c5f01b2fSopenharmony_ci                it.set_begin();
90c5f01b2fSopenharmony_ci                CHECK((it == j.cbegin()));
91c5f01b2fSopenharmony_ci            }
92c5f01b2fSopenharmony_ci        }
93c5f01b2fSopenharmony_ci
94c5f01b2fSopenharmony_ci        SECTION("set_end")
95c5f01b2fSopenharmony_ci        {
96c5f01b2fSopenharmony_ci            SECTION("null")
97c5f01b2fSopenharmony_ci            {
98c5f01b2fSopenharmony_ci                json j(json::value_t::null);
99c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
100c5f01b2fSopenharmony_ci                it.set_end();
101c5f01b2fSopenharmony_ci                CHECK((it == j.cend()));
102c5f01b2fSopenharmony_ci            }
103c5f01b2fSopenharmony_ci
104c5f01b2fSopenharmony_ci            SECTION("object")
105c5f01b2fSopenharmony_ci            {
106c5f01b2fSopenharmony_ci                json j(json::value_t::object);
107c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
108c5f01b2fSopenharmony_ci                it.set_end();
109c5f01b2fSopenharmony_ci                CHECK((it == j.cend()));
110c5f01b2fSopenharmony_ci            }
111c5f01b2fSopenharmony_ci
112c5f01b2fSopenharmony_ci            SECTION("array")
113c5f01b2fSopenharmony_ci            {
114c5f01b2fSopenharmony_ci                json j(json::value_t::array);
115c5f01b2fSopenharmony_ci                json::const_iterator it(&j);
116c5f01b2fSopenharmony_ci                it.set_end();
117c5f01b2fSopenharmony_ci                CHECK((it == j.cend()));
118c5f01b2fSopenharmony_ci            }
119c5f01b2fSopenharmony_ci        }
120c5f01b2fSopenharmony_ci    }
121c5f01b2fSopenharmony_ci
122c5f01b2fSopenharmony_ci    SECTION("element access")
123c5f01b2fSopenharmony_ci    {
124c5f01b2fSopenharmony_ci        SECTION("operator*")
125c5f01b2fSopenharmony_ci        {
126c5f01b2fSopenharmony_ci            SECTION("null")
127c5f01b2fSopenharmony_ci            {
128c5f01b2fSopenharmony_ci                json j(json::value_t::null);
129c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
130c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
131c5f01b2fSopenharmony_ci            }
132c5f01b2fSopenharmony_ci
133c5f01b2fSopenharmony_ci            SECTION("number")
134c5f01b2fSopenharmony_ci            {
135c5f01b2fSopenharmony_ci                json j(17);
136c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
137c5f01b2fSopenharmony_ci                CHECK(*it == json(17));
138c5f01b2fSopenharmony_ci                it = j.cend();
139c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
140c5f01b2fSopenharmony_ci            }
141c5f01b2fSopenharmony_ci
142c5f01b2fSopenharmony_ci            SECTION("object")
143c5f01b2fSopenharmony_ci            {
144c5f01b2fSopenharmony_ci                json j({{"foo", "bar"}});
145c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
146c5f01b2fSopenharmony_ci                CHECK(*it == json("bar"));
147c5f01b2fSopenharmony_ci            }
148c5f01b2fSopenharmony_ci
149c5f01b2fSopenharmony_ci            SECTION("array")
150c5f01b2fSopenharmony_ci            {
151c5f01b2fSopenharmony_ci                json j({1, 2, 3, 4});
152c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
153c5f01b2fSopenharmony_ci                CHECK(*it == json(1));
154c5f01b2fSopenharmony_ci            }
155c5f01b2fSopenharmony_ci        }
156c5f01b2fSopenharmony_ci
157c5f01b2fSopenharmony_ci        SECTION("operator->")
158c5f01b2fSopenharmony_ci        {
159c5f01b2fSopenharmony_ci            SECTION("null")
160c5f01b2fSopenharmony_ci            {
161c5f01b2fSopenharmony_ci                json j(json::value_t::null);
162c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
163c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
164c5f01b2fSopenharmony_ci            }
165c5f01b2fSopenharmony_ci
166c5f01b2fSopenharmony_ci            SECTION("number")
167c5f01b2fSopenharmony_ci            {
168c5f01b2fSopenharmony_ci                json j(17);
169c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
170c5f01b2fSopenharmony_ci                CHECK(std::string(it->type_name()) == "number");
171c5f01b2fSopenharmony_ci                it = j.cend();
172c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
173c5f01b2fSopenharmony_ci            }
174c5f01b2fSopenharmony_ci
175c5f01b2fSopenharmony_ci            SECTION("object")
176c5f01b2fSopenharmony_ci            {
177c5f01b2fSopenharmony_ci                json j({{"foo", "bar"}});
178c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
179c5f01b2fSopenharmony_ci                CHECK(std::string(it->type_name()) == "string");
180c5f01b2fSopenharmony_ci            }
181c5f01b2fSopenharmony_ci
182c5f01b2fSopenharmony_ci            SECTION("array")
183c5f01b2fSopenharmony_ci            {
184c5f01b2fSopenharmony_ci                json j({1, 2, 3, 4});
185c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
186c5f01b2fSopenharmony_ci                CHECK(std::string(it->type_name()) == "number");
187c5f01b2fSopenharmony_ci            }
188c5f01b2fSopenharmony_ci        }
189c5f01b2fSopenharmony_ci    }
190c5f01b2fSopenharmony_ci
191c5f01b2fSopenharmony_ci    SECTION("increment/decrement")
192c5f01b2fSopenharmony_ci    {
193c5f01b2fSopenharmony_ci        SECTION("post-increment")
194c5f01b2fSopenharmony_ci        {
195c5f01b2fSopenharmony_ci            SECTION("null")
196c5f01b2fSopenharmony_ci            {
197c5f01b2fSopenharmony_ci                json j(json::value_t::null);
198c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
199c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
200c5f01b2fSopenharmony_ci                it++;
201c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
202c5f01b2fSopenharmony_ci            }
203c5f01b2fSopenharmony_ci
204c5f01b2fSopenharmony_ci            SECTION("number")
205c5f01b2fSopenharmony_ci            {
206c5f01b2fSopenharmony_ci                json j(17);
207c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
208c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 0));
209c5f01b2fSopenharmony_ci                it++;
210c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
211c5f01b2fSopenharmony_ci                it++;
212c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
213c5f01b2fSopenharmony_ci            }
214c5f01b2fSopenharmony_ci
215c5f01b2fSopenharmony_ci            SECTION("object")
216c5f01b2fSopenharmony_ci            {
217c5f01b2fSopenharmony_ci                json j({{"foo", "bar"}});
218c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
219c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()));
220c5f01b2fSopenharmony_ci                it++;
221c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
222c5f01b2fSopenharmony_ci            }
223c5f01b2fSopenharmony_ci
224c5f01b2fSopenharmony_ci            SECTION("array")
225c5f01b2fSopenharmony_ci            {
226c5f01b2fSopenharmony_ci                json j({1, 2, 3, 4});
227c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
228c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
229c5f01b2fSopenharmony_ci                it++;
230c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
231c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
232c5f01b2fSopenharmony_ci                it++;
233c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
234c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
235c5f01b2fSopenharmony_ci                it++;
236c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
237c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
238c5f01b2fSopenharmony_ci                it++;
239c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
240c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
241c5f01b2fSopenharmony_ci            }
242c5f01b2fSopenharmony_ci        }
243c5f01b2fSopenharmony_ci
244c5f01b2fSopenharmony_ci        SECTION("pre-increment")
245c5f01b2fSopenharmony_ci        {
246c5f01b2fSopenharmony_ci            SECTION("null")
247c5f01b2fSopenharmony_ci            {
248c5f01b2fSopenharmony_ci                json j(json::value_t::null);
249c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
250c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
251c5f01b2fSopenharmony_ci                ++it;
252c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
253c5f01b2fSopenharmony_ci            }
254c5f01b2fSopenharmony_ci
255c5f01b2fSopenharmony_ci            SECTION("number")
256c5f01b2fSopenharmony_ci            {
257c5f01b2fSopenharmony_ci                json j(17);
258c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
259c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 0));
260c5f01b2fSopenharmony_ci                ++it;
261c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
262c5f01b2fSopenharmony_ci                ++it;
263c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
264c5f01b2fSopenharmony_ci            }
265c5f01b2fSopenharmony_ci
266c5f01b2fSopenharmony_ci            SECTION("object")
267c5f01b2fSopenharmony_ci            {
268c5f01b2fSopenharmony_ci                json j({{"foo", "bar"}});
269c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
270c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()));
271c5f01b2fSopenharmony_ci                ++it;
272c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
273c5f01b2fSopenharmony_ci            }
274c5f01b2fSopenharmony_ci
275c5f01b2fSopenharmony_ci            SECTION("array")
276c5f01b2fSopenharmony_ci            {
277c5f01b2fSopenharmony_ci                json j({1, 2, 3, 4});
278c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
279c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
280c5f01b2fSopenharmony_ci                ++it;
281c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
282c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
283c5f01b2fSopenharmony_ci                ++it;
284c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
285c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
286c5f01b2fSopenharmony_ci                ++it;
287c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
288c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
289c5f01b2fSopenharmony_ci                ++it;
290c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
291c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
292c5f01b2fSopenharmony_ci            }
293c5f01b2fSopenharmony_ci        }
294c5f01b2fSopenharmony_ci
295c5f01b2fSopenharmony_ci        SECTION("post-decrement")
296c5f01b2fSopenharmony_ci        {
297c5f01b2fSopenharmony_ci            SECTION("null")
298c5f01b2fSopenharmony_ci            {
299c5f01b2fSopenharmony_ci                json j(json::value_t::null);
300c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
301c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
302c5f01b2fSopenharmony_ci            }
303c5f01b2fSopenharmony_ci
304c5f01b2fSopenharmony_ci            SECTION("number")
305c5f01b2fSopenharmony_ci            {
306c5f01b2fSopenharmony_ci                json j(17);
307c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
308c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
309c5f01b2fSopenharmony_ci                it--;
310c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 0));
311c5f01b2fSopenharmony_ci                it--;
312c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
313c5f01b2fSopenharmony_ci            }
314c5f01b2fSopenharmony_ci
315c5f01b2fSopenharmony_ci            SECTION("object")
316c5f01b2fSopenharmony_ci            {
317c5f01b2fSopenharmony_ci                json j({{"foo", "bar"}});
318c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
319c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
320c5f01b2fSopenharmony_ci                it--;
321c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()));
322c5f01b2fSopenharmony_ci            }
323c5f01b2fSopenharmony_ci
324c5f01b2fSopenharmony_ci            SECTION("array")
325c5f01b2fSopenharmony_ci            {
326c5f01b2fSopenharmony_ci                json j({1, 2, 3, 4});
327c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
328c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
329c5f01b2fSopenharmony_ci                it--;
330c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
331c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
332c5f01b2fSopenharmony_ci                it--;
333c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
334c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
335c5f01b2fSopenharmony_ci                it--;
336c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
337c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
338c5f01b2fSopenharmony_ci                it--;
339c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
340c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
341c5f01b2fSopenharmony_ci            }
342c5f01b2fSopenharmony_ci        }
343c5f01b2fSopenharmony_ci
344c5f01b2fSopenharmony_ci        SECTION("pre-decrement")
345c5f01b2fSopenharmony_ci        {
346c5f01b2fSopenharmony_ci            SECTION("null")
347c5f01b2fSopenharmony_ci            {
348c5f01b2fSopenharmony_ci                json j(json::value_t::null);
349c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
350c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
351c5f01b2fSopenharmony_ci            }
352c5f01b2fSopenharmony_ci
353c5f01b2fSopenharmony_ci            SECTION("number")
354c5f01b2fSopenharmony_ci            {
355c5f01b2fSopenharmony_ci                json j(17);
356c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
357c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 1));
358c5f01b2fSopenharmony_ci                --it;
359c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it == 0));
360c5f01b2fSopenharmony_ci                --it;
361c5f01b2fSopenharmony_ci                CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterator.m_it != 1));
362c5f01b2fSopenharmony_ci            }
363c5f01b2fSopenharmony_ci
364c5f01b2fSopenharmony_ci            SECTION("object")
365c5f01b2fSopenharmony_ci            {
366c5f01b2fSopenharmony_ci                json j({{"foo", "bar"}});
367c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
368c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
369c5f01b2fSopenharmony_ci                --it;
370c5f01b2fSopenharmony_ci                CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()));
371c5f01b2fSopenharmony_ci            }
372c5f01b2fSopenharmony_ci
373c5f01b2fSopenharmony_ci            SECTION("array")
374c5f01b2fSopenharmony_ci            {
375c5f01b2fSopenharmony_ci                json j({1, 2, 3, 4});
376c5f01b2fSopenharmony_ci                json::const_iterator it = j.cend();
377c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
378c5f01b2fSopenharmony_ci                --it;
379c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
380c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
381c5f01b2fSopenharmony_ci                --it;
382c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
383c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
384c5f01b2fSopenharmony_ci                --it;
385c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
386c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
387c5f01b2fSopenharmony_ci                --it;
388c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
389c5f01b2fSopenharmony_ci                CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
390c5f01b2fSopenharmony_ci            }
391c5f01b2fSopenharmony_ci        }
392c5f01b2fSopenharmony_ci    }
393c5f01b2fSopenharmony_ci}
394