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("iterators 1")
16c5f01b2fSopenharmony_ci{
17c5f01b2fSopenharmony_ci    SECTION("basic behavior")
18c5f01b2fSopenharmony_ci    {
19c5f01b2fSopenharmony_ci        SECTION("uninitialized")
20c5f01b2fSopenharmony_ci        {
21c5f01b2fSopenharmony_ci            json::iterator it;
22c5f01b2fSopenharmony_ci            CHECK(it.m_object == nullptr);
23c5f01b2fSopenharmony_ci
24c5f01b2fSopenharmony_ci            json::const_iterator cit;
25c5f01b2fSopenharmony_ci            CHECK(cit.m_object == nullptr);
26c5f01b2fSopenharmony_ci        }
27c5f01b2fSopenharmony_ci
28c5f01b2fSopenharmony_ci        SECTION("boolean")
29c5f01b2fSopenharmony_ci        {
30c5f01b2fSopenharmony_ci            json j = true;
31c5f01b2fSopenharmony_ci            json j_const(j);
32c5f01b2fSopenharmony_ci
33c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
34c5f01b2fSopenharmony_ci            {
35c5f01b2fSopenharmony_ci                json::iterator it = j.begin();
36c5f01b2fSopenharmony_ci                CHECK(it != j.end());
37c5f01b2fSopenharmony_ci                CHECK(*it == j);
38c5f01b2fSopenharmony_ci
39c5f01b2fSopenharmony_ci                it++;
40c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
41c5f01b2fSopenharmony_ci                CHECK(it == j.end());
42c5f01b2fSopenharmony_ci
43c5f01b2fSopenharmony_ci                it--;
44c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
45c5f01b2fSopenharmony_ci                CHECK(it != j.end());
46c5f01b2fSopenharmony_ci                CHECK(*it == j);
47c5f01b2fSopenharmony_ci
48c5f01b2fSopenharmony_ci                ++it;
49c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
50c5f01b2fSopenharmony_ci                CHECK(it == j.end());
51c5f01b2fSopenharmony_ci
52c5f01b2fSopenharmony_ci                --it;
53c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
54c5f01b2fSopenharmony_ci                CHECK(it != j.end());
55c5f01b2fSopenharmony_ci                CHECK(*it == j);
56c5f01b2fSopenharmony_ci            }
57c5f01b2fSopenharmony_ci
58c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
59c5f01b2fSopenharmony_ci            {
60c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.begin();
61c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
62c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
63c5f01b2fSopenharmony_ci
64c5f01b2fSopenharmony_ci                it++;
65c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
66c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
67c5f01b2fSopenharmony_ci
68c5f01b2fSopenharmony_ci                it--;
69c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
70c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
71c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
72c5f01b2fSopenharmony_ci
73c5f01b2fSopenharmony_ci                ++it;
74c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
75c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
76c5f01b2fSopenharmony_ci
77c5f01b2fSopenharmony_ci                --it;
78c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
79c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
80c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
81c5f01b2fSopenharmony_ci            }
82c5f01b2fSopenharmony_ci
83c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
84c5f01b2fSopenharmony_ci            {
85c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
86c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
87c5f01b2fSopenharmony_ci                CHECK(*it == j);
88c5f01b2fSopenharmony_ci
89c5f01b2fSopenharmony_ci                it++;
90c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
91c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
92c5f01b2fSopenharmony_ci
93c5f01b2fSopenharmony_ci                it--;
94c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
95c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
96c5f01b2fSopenharmony_ci                CHECK(*it == j);
97c5f01b2fSopenharmony_ci
98c5f01b2fSopenharmony_ci                ++it;
99c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
100c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
101c5f01b2fSopenharmony_ci
102c5f01b2fSopenharmony_ci                --it;
103c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
104c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
105c5f01b2fSopenharmony_ci                CHECK(*it == j);
106c5f01b2fSopenharmony_ci            }
107c5f01b2fSopenharmony_ci
108c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
109c5f01b2fSopenharmony_ci            {
110c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.cbegin();
111c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
112c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
113c5f01b2fSopenharmony_ci
114c5f01b2fSopenharmony_ci                it++;
115c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
116c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
117c5f01b2fSopenharmony_ci
118c5f01b2fSopenharmony_ci                it--;
119c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
120c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
121c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
122c5f01b2fSopenharmony_ci
123c5f01b2fSopenharmony_ci                ++it;
124c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
125c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
126c5f01b2fSopenharmony_ci
127c5f01b2fSopenharmony_ci                --it;
128c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
129c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
130c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
131c5f01b2fSopenharmony_ci            }
132c5f01b2fSopenharmony_ci
133c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
134c5f01b2fSopenharmony_ci            {
135c5f01b2fSopenharmony_ci                json::reverse_iterator it = j.rbegin();
136c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
137c5f01b2fSopenharmony_ci                CHECK(*it == j);
138c5f01b2fSopenharmony_ci
139c5f01b2fSopenharmony_ci                it++;
140c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
141c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
142c5f01b2fSopenharmony_ci
143c5f01b2fSopenharmony_ci                it--;
144c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
145c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
146c5f01b2fSopenharmony_ci                CHECK(*it == j);
147c5f01b2fSopenharmony_ci
148c5f01b2fSopenharmony_ci                ++it;
149c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
150c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
151c5f01b2fSopenharmony_ci
152c5f01b2fSopenharmony_ci                --it;
153c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
154c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
155c5f01b2fSopenharmony_ci                CHECK(*it == j);
156c5f01b2fSopenharmony_ci            }
157c5f01b2fSopenharmony_ci
158c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
159c5f01b2fSopenharmony_ci            {
160c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j.crbegin();
161c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
162c5f01b2fSopenharmony_ci                CHECK(*it == j);
163c5f01b2fSopenharmony_ci
164c5f01b2fSopenharmony_ci                it++;
165c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
166c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
167c5f01b2fSopenharmony_ci
168c5f01b2fSopenharmony_ci                it--;
169c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
170c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
171c5f01b2fSopenharmony_ci                CHECK(*it == j);
172c5f01b2fSopenharmony_ci
173c5f01b2fSopenharmony_ci                ++it;
174c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
175c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
176c5f01b2fSopenharmony_ci
177c5f01b2fSopenharmony_ci                --it;
178c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
179c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
180c5f01b2fSopenharmony_ci                CHECK(*it == j);
181c5f01b2fSopenharmony_ci            }
182c5f01b2fSopenharmony_ci
183c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
184c5f01b2fSopenharmony_ci            {
185c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j_const.crbegin();
186c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
187c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
188c5f01b2fSopenharmony_ci
189c5f01b2fSopenharmony_ci                it++;
190c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
191c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
192c5f01b2fSopenharmony_ci
193c5f01b2fSopenharmony_ci                it--;
194c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
195c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
196c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
197c5f01b2fSopenharmony_ci
198c5f01b2fSopenharmony_ci                ++it;
199c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
200c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
201c5f01b2fSopenharmony_ci
202c5f01b2fSopenharmony_ci                --it;
203c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
204c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
205c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
206c5f01b2fSopenharmony_ci            }
207c5f01b2fSopenharmony_ci
208c5f01b2fSopenharmony_ci            SECTION("additional tests")
209c5f01b2fSopenharmony_ci            {
210c5f01b2fSopenharmony_ci                SECTION("!(begin != begin)")
211c5f01b2fSopenharmony_ci                {
212c5f01b2fSopenharmony_ci                    CHECK(!(j.begin() != j.begin()));
213c5f01b2fSopenharmony_ci                }
214c5f01b2fSopenharmony_ci
215c5f01b2fSopenharmony_ci                SECTION("!(end != end)")
216c5f01b2fSopenharmony_ci                {
217c5f01b2fSopenharmony_ci                    CHECK(!(j.end() != j.end()));
218c5f01b2fSopenharmony_ci                }
219c5f01b2fSopenharmony_ci
220c5f01b2fSopenharmony_ci                SECTION("begin < end")
221c5f01b2fSopenharmony_ci                {
222c5f01b2fSopenharmony_ci                    CHECK(j.begin() < j.end());
223c5f01b2fSopenharmony_ci                }
224c5f01b2fSopenharmony_ci
225c5f01b2fSopenharmony_ci                SECTION("begin <= end")
226c5f01b2fSopenharmony_ci                {
227c5f01b2fSopenharmony_ci                    CHECK(j.begin() <= j.end());
228c5f01b2fSopenharmony_ci                }
229c5f01b2fSopenharmony_ci
230c5f01b2fSopenharmony_ci                SECTION("end > begin")
231c5f01b2fSopenharmony_ci                {
232c5f01b2fSopenharmony_ci                    CHECK(j.end() > j.begin());
233c5f01b2fSopenharmony_ci                }
234c5f01b2fSopenharmony_ci
235c5f01b2fSopenharmony_ci                SECTION("end >= begin")
236c5f01b2fSopenharmony_ci                {
237c5f01b2fSopenharmony_ci                    CHECK(j.end() >= j.begin());
238c5f01b2fSopenharmony_ci                }
239c5f01b2fSopenharmony_ci
240c5f01b2fSopenharmony_ci                SECTION("end == end")
241c5f01b2fSopenharmony_ci                {
242c5f01b2fSopenharmony_ci                    CHECK(j.end() == j.end());
243c5f01b2fSopenharmony_ci                }
244c5f01b2fSopenharmony_ci
245c5f01b2fSopenharmony_ci                SECTION("end <= end")
246c5f01b2fSopenharmony_ci                {
247c5f01b2fSopenharmony_ci                    CHECK(j.end() <= j.end());
248c5f01b2fSopenharmony_ci                }
249c5f01b2fSopenharmony_ci
250c5f01b2fSopenharmony_ci                SECTION("begin == begin")
251c5f01b2fSopenharmony_ci                {
252c5f01b2fSopenharmony_ci                    CHECK(j.begin() == j.begin());
253c5f01b2fSopenharmony_ci                }
254c5f01b2fSopenharmony_ci
255c5f01b2fSopenharmony_ci                SECTION("begin <= begin")
256c5f01b2fSopenharmony_ci                {
257c5f01b2fSopenharmony_ci                    CHECK(j.begin() <= j.begin());
258c5f01b2fSopenharmony_ci                }
259c5f01b2fSopenharmony_ci
260c5f01b2fSopenharmony_ci                SECTION("begin >= begin")
261c5f01b2fSopenharmony_ci                {
262c5f01b2fSopenharmony_ci                    CHECK(j.begin() >= j.begin());
263c5f01b2fSopenharmony_ci                }
264c5f01b2fSopenharmony_ci
265c5f01b2fSopenharmony_ci                SECTION("!(begin == end)")
266c5f01b2fSopenharmony_ci                {
267c5f01b2fSopenharmony_ci                    CHECK(!(j.begin() == j.end()));
268c5f01b2fSopenharmony_ci                }
269c5f01b2fSopenharmony_ci
270c5f01b2fSopenharmony_ci                SECTION("begin != end")
271c5f01b2fSopenharmony_ci                {
272c5f01b2fSopenharmony_ci                    CHECK(j.begin() != j.end());
273c5f01b2fSopenharmony_ci                }
274c5f01b2fSopenharmony_ci
275c5f01b2fSopenharmony_ci                SECTION("begin+1 == end")
276c5f01b2fSopenharmony_ci                {
277c5f01b2fSopenharmony_ci                    CHECK(j.begin() + 1 == j.end());
278c5f01b2fSopenharmony_ci                }
279c5f01b2fSopenharmony_ci
280c5f01b2fSopenharmony_ci                SECTION("begin == end-1")
281c5f01b2fSopenharmony_ci                {
282c5f01b2fSopenharmony_ci                    CHECK(j.begin() == j.end() - 1);
283c5f01b2fSopenharmony_ci                }
284c5f01b2fSopenharmony_ci
285c5f01b2fSopenharmony_ci                SECTION("begin != end+1")
286c5f01b2fSopenharmony_ci                {
287c5f01b2fSopenharmony_ci                    CHECK(j.begin() != j.end() + 1);
288c5f01b2fSopenharmony_ci                }
289c5f01b2fSopenharmony_ci
290c5f01b2fSopenharmony_ci                SECTION("end != end+1")
291c5f01b2fSopenharmony_ci                {
292c5f01b2fSopenharmony_ci                    CHECK(j.end() != j.end() + 1);
293c5f01b2fSopenharmony_ci                }
294c5f01b2fSopenharmony_ci
295c5f01b2fSopenharmony_ci                SECTION("begin+1 != begin+2")
296c5f01b2fSopenharmony_ci                {
297c5f01b2fSopenharmony_ci                    CHECK(j.begin() + 1 != j.begin() + 2);
298c5f01b2fSopenharmony_ci                }
299c5f01b2fSopenharmony_ci
300c5f01b2fSopenharmony_ci                SECTION("begin+1 < begin+2")
301c5f01b2fSopenharmony_ci                {
302c5f01b2fSopenharmony_ci                    CHECK(j.begin() + 1 < j.begin() + 2);
303c5f01b2fSopenharmony_ci                }
304c5f01b2fSopenharmony_ci
305c5f01b2fSopenharmony_ci                SECTION("begin+1 <= begin+2")
306c5f01b2fSopenharmony_ci                {
307c5f01b2fSopenharmony_ci                    CHECK(j.begin() + 1 <= j.begin() + 2);
308c5f01b2fSopenharmony_ci                }
309c5f01b2fSopenharmony_ci
310c5f01b2fSopenharmony_ci                SECTION("end+1 != end+2")
311c5f01b2fSopenharmony_ci                {
312c5f01b2fSopenharmony_ci                    CHECK(j.end() + 1 != j.end() + 2);
313c5f01b2fSopenharmony_ci                }
314c5f01b2fSopenharmony_ci            }
315c5f01b2fSopenharmony_ci
316c5f01b2fSopenharmony_ci            SECTION("key/value")
317c5f01b2fSopenharmony_ci            {
318c5f01b2fSopenharmony_ci                auto it = j.begin();
319c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
320c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
321c5f01b2fSopenharmony_ci                CHECK(it.value() == json(true));
322c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
323c5f01b2fSopenharmony_ci                CHECK(cit.value() == json(true));
324c5f01b2fSopenharmony_ci
325c5f01b2fSopenharmony_ci                auto rit = j.rend();
326c5f01b2fSopenharmony_ci                auto crit = j.crend();
327c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
328c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
329c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
330c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
331c5f01b2fSopenharmony_ci            }
332c5f01b2fSopenharmony_ci        }
333c5f01b2fSopenharmony_ci
334c5f01b2fSopenharmony_ci        SECTION("string")
335c5f01b2fSopenharmony_ci        {
336c5f01b2fSopenharmony_ci            json j = "hello world";
337c5f01b2fSopenharmony_ci            json j_const(j);
338c5f01b2fSopenharmony_ci
339c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
340c5f01b2fSopenharmony_ci            {
341c5f01b2fSopenharmony_ci                json::iterator it = j.begin();
342c5f01b2fSopenharmony_ci                CHECK(it != j.end());
343c5f01b2fSopenharmony_ci                CHECK(*it == j);
344c5f01b2fSopenharmony_ci
345c5f01b2fSopenharmony_ci                it++;
346c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
347c5f01b2fSopenharmony_ci                CHECK(it == j.end());
348c5f01b2fSopenharmony_ci
349c5f01b2fSopenharmony_ci                it--;
350c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
351c5f01b2fSopenharmony_ci                CHECK(it != j.end());
352c5f01b2fSopenharmony_ci                CHECK(*it == j);
353c5f01b2fSopenharmony_ci
354c5f01b2fSopenharmony_ci                ++it;
355c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
356c5f01b2fSopenharmony_ci                CHECK(it == j.end());
357c5f01b2fSopenharmony_ci
358c5f01b2fSopenharmony_ci                --it;
359c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
360c5f01b2fSopenharmony_ci                CHECK(it != j.end());
361c5f01b2fSopenharmony_ci                CHECK(*it == j);
362c5f01b2fSopenharmony_ci            }
363c5f01b2fSopenharmony_ci
364c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
365c5f01b2fSopenharmony_ci            {
366c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.begin();
367c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
368c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
369c5f01b2fSopenharmony_ci
370c5f01b2fSopenharmony_ci                it++;
371c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
372c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
373c5f01b2fSopenharmony_ci
374c5f01b2fSopenharmony_ci                it--;
375c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
376c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
377c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
378c5f01b2fSopenharmony_ci
379c5f01b2fSopenharmony_ci                ++it;
380c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
381c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
382c5f01b2fSopenharmony_ci
383c5f01b2fSopenharmony_ci                --it;
384c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
385c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
386c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
387c5f01b2fSopenharmony_ci            }
388c5f01b2fSopenharmony_ci
389c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
390c5f01b2fSopenharmony_ci            {
391c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
392c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
393c5f01b2fSopenharmony_ci                CHECK(*it == j);
394c5f01b2fSopenharmony_ci
395c5f01b2fSopenharmony_ci                it++;
396c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
397c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
398c5f01b2fSopenharmony_ci
399c5f01b2fSopenharmony_ci                it--;
400c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
401c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
402c5f01b2fSopenharmony_ci                CHECK(*it == j);
403c5f01b2fSopenharmony_ci
404c5f01b2fSopenharmony_ci                ++it;
405c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
406c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
407c5f01b2fSopenharmony_ci
408c5f01b2fSopenharmony_ci                --it;
409c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
410c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
411c5f01b2fSopenharmony_ci                CHECK(*it == j);
412c5f01b2fSopenharmony_ci            }
413c5f01b2fSopenharmony_ci
414c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
415c5f01b2fSopenharmony_ci            {
416c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.cbegin();
417c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
418c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
419c5f01b2fSopenharmony_ci
420c5f01b2fSopenharmony_ci                it++;
421c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
422c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
423c5f01b2fSopenharmony_ci
424c5f01b2fSopenharmony_ci                it--;
425c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
426c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
427c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
428c5f01b2fSopenharmony_ci
429c5f01b2fSopenharmony_ci                ++it;
430c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
431c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
432c5f01b2fSopenharmony_ci
433c5f01b2fSopenharmony_ci                --it;
434c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
435c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
436c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
437c5f01b2fSopenharmony_ci            }
438c5f01b2fSopenharmony_ci
439c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
440c5f01b2fSopenharmony_ci            {
441c5f01b2fSopenharmony_ci                json::reverse_iterator it = j.rbegin();
442c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
443c5f01b2fSopenharmony_ci                CHECK(*it == j);
444c5f01b2fSopenharmony_ci
445c5f01b2fSopenharmony_ci                it++;
446c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
447c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
448c5f01b2fSopenharmony_ci
449c5f01b2fSopenharmony_ci                it--;
450c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
451c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
452c5f01b2fSopenharmony_ci                CHECK(*it == j);
453c5f01b2fSopenharmony_ci
454c5f01b2fSopenharmony_ci                ++it;
455c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
456c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
457c5f01b2fSopenharmony_ci
458c5f01b2fSopenharmony_ci                --it;
459c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
460c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
461c5f01b2fSopenharmony_ci                CHECK(*it == j);
462c5f01b2fSopenharmony_ci            }
463c5f01b2fSopenharmony_ci
464c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
465c5f01b2fSopenharmony_ci            {
466c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j.crbegin();
467c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
468c5f01b2fSopenharmony_ci                CHECK(*it == j);
469c5f01b2fSopenharmony_ci
470c5f01b2fSopenharmony_ci                it++;
471c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
472c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
473c5f01b2fSopenharmony_ci
474c5f01b2fSopenharmony_ci                it--;
475c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
476c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
477c5f01b2fSopenharmony_ci                CHECK(*it == j);
478c5f01b2fSopenharmony_ci
479c5f01b2fSopenharmony_ci                ++it;
480c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
481c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
482c5f01b2fSopenharmony_ci
483c5f01b2fSopenharmony_ci                --it;
484c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
485c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
486c5f01b2fSopenharmony_ci                CHECK(*it == j);
487c5f01b2fSopenharmony_ci            }
488c5f01b2fSopenharmony_ci
489c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
490c5f01b2fSopenharmony_ci            {
491c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j_const.crbegin();
492c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
493c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
494c5f01b2fSopenharmony_ci
495c5f01b2fSopenharmony_ci                it++;
496c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
497c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
498c5f01b2fSopenharmony_ci
499c5f01b2fSopenharmony_ci                it--;
500c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
501c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
502c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
503c5f01b2fSopenharmony_ci
504c5f01b2fSopenharmony_ci                ++it;
505c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
506c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
507c5f01b2fSopenharmony_ci
508c5f01b2fSopenharmony_ci                --it;
509c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
510c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
511c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
512c5f01b2fSopenharmony_ci            }
513c5f01b2fSopenharmony_ci
514c5f01b2fSopenharmony_ci            SECTION("key/value")
515c5f01b2fSopenharmony_ci            {
516c5f01b2fSopenharmony_ci                auto it = j.begin();
517c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
518c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
519c5f01b2fSopenharmony_ci                CHECK(it.value() == json("hello world"));
520c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
521c5f01b2fSopenharmony_ci                CHECK(cit.value() == json("hello world"));
522c5f01b2fSopenharmony_ci
523c5f01b2fSopenharmony_ci                auto rit = j.rend();
524c5f01b2fSopenharmony_ci                auto crit = j.crend();
525c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
526c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
527c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
528c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
529c5f01b2fSopenharmony_ci            }
530c5f01b2fSopenharmony_ci        }
531c5f01b2fSopenharmony_ci
532c5f01b2fSopenharmony_ci        SECTION("array")
533c5f01b2fSopenharmony_ci        {
534c5f01b2fSopenharmony_ci            json j = {1, 2, 3};
535c5f01b2fSopenharmony_ci            json j_const(j);
536c5f01b2fSopenharmony_ci
537c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
538c5f01b2fSopenharmony_ci            {
539c5f01b2fSopenharmony_ci                json::iterator it_begin = j.begin();
540c5f01b2fSopenharmony_ci                json::iterator it_end = j.end();
541c5f01b2fSopenharmony_ci
542c5f01b2fSopenharmony_ci                auto it = it_begin;
543c5f01b2fSopenharmony_ci                CHECK(it != it_end);
544c5f01b2fSopenharmony_ci                CHECK(*it == j[0]);
545c5f01b2fSopenharmony_ci
546c5f01b2fSopenharmony_ci                it++;
547c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
548c5f01b2fSopenharmony_ci                CHECK(it != it_end);
549c5f01b2fSopenharmony_ci                CHECK(*it == j[1]);
550c5f01b2fSopenharmony_ci
551c5f01b2fSopenharmony_ci                ++it;
552c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
553c5f01b2fSopenharmony_ci                CHECK(it != it_end);
554c5f01b2fSopenharmony_ci                CHECK(*it == j[2]);
555c5f01b2fSopenharmony_ci
556c5f01b2fSopenharmony_ci                ++it;
557c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
558c5f01b2fSopenharmony_ci                CHECK(it == it_end);
559c5f01b2fSopenharmony_ci            }
560c5f01b2fSopenharmony_ci
561c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
562c5f01b2fSopenharmony_ci            {
563c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j_const.begin();
564c5f01b2fSopenharmony_ci                json::const_iterator it_end = j_const.end();
565c5f01b2fSopenharmony_ci
566c5f01b2fSopenharmony_ci                auto it = it_begin;
567c5f01b2fSopenharmony_ci                CHECK(it != it_end);
568c5f01b2fSopenharmony_ci                CHECK(*it == j_const[0]);
569c5f01b2fSopenharmony_ci
570c5f01b2fSopenharmony_ci                it++;
571c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
572c5f01b2fSopenharmony_ci                CHECK(it != it_end);
573c5f01b2fSopenharmony_ci                CHECK(*it == j_const[1]);
574c5f01b2fSopenharmony_ci
575c5f01b2fSopenharmony_ci                ++it;
576c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
577c5f01b2fSopenharmony_ci                CHECK(it != it_end);
578c5f01b2fSopenharmony_ci                CHECK(*it == j_const[2]);
579c5f01b2fSopenharmony_ci
580c5f01b2fSopenharmony_ci                ++it;
581c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
582c5f01b2fSopenharmony_ci                CHECK(it == it_end);
583c5f01b2fSopenharmony_ci            }
584c5f01b2fSopenharmony_ci
585c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
586c5f01b2fSopenharmony_ci            {
587c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j.cbegin();
588c5f01b2fSopenharmony_ci                json::const_iterator it_end = j.cend();
589c5f01b2fSopenharmony_ci
590c5f01b2fSopenharmony_ci                auto it = it_begin;
591c5f01b2fSopenharmony_ci                CHECK(it != it_end);
592c5f01b2fSopenharmony_ci                CHECK(*it == j[0]);
593c5f01b2fSopenharmony_ci
594c5f01b2fSopenharmony_ci                it++;
595c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
596c5f01b2fSopenharmony_ci                CHECK(it != it_end);
597c5f01b2fSopenharmony_ci                CHECK(*it == j[1]);
598c5f01b2fSopenharmony_ci
599c5f01b2fSopenharmony_ci                ++it;
600c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
601c5f01b2fSopenharmony_ci                CHECK(it != it_end);
602c5f01b2fSopenharmony_ci                CHECK(*it == j[2]);
603c5f01b2fSopenharmony_ci
604c5f01b2fSopenharmony_ci                ++it;
605c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
606c5f01b2fSopenharmony_ci                CHECK(it == it_end);
607c5f01b2fSopenharmony_ci            }
608c5f01b2fSopenharmony_ci
609c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
610c5f01b2fSopenharmony_ci            {
611c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j_const.cbegin();
612c5f01b2fSopenharmony_ci                json::const_iterator it_end = j_const.cend();
613c5f01b2fSopenharmony_ci
614c5f01b2fSopenharmony_ci                auto it = it_begin;
615c5f01b2fSopenharmony_ci                CHECK(it != it_end);
616c5f01b2fSopenharmony_ci                CHECK(*it == j[0]);
617c5f01b2fSopenharmony_ci
618c5f01b2fSopenharmony_ci                it++;
619c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
620c5f01b2fSopenharmony_ci                CHECK(it != it_end);
621c5f01b2fSopenharmony_ci                CHECK(*it == j[1]);
622c5f01b2fSopenharmony_ci
623c5f01b2fSopenharmony_ci                ++it;
624c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
625c5f01b2fSopenharmony_ci                CHECK(it != it_end);
626c5f01b2fSopenharmony_ci                CHECK(*it == j[2]);
627c5f01b2fSopenharmony_ci
628c5f01b2fSopenharmony_ci                ++it;
629c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
630c5f01b2fSopenharmony_ci                CHECK(it == it_end);
631c5f01b2fSopenharmony_ci            }
632c5f01b2fSopenharmony_ci
633c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
634c5f01b2fSopenharmony_ci            {
635c5f01b2fSopenharmony_ci                json::reverse_iterator it_begin = j.rbegin();
636c5f01b2fSopenharmony_ci                json::reverse_iterator it_end = j.rend();
637c5f01b2fSopenharmony_ci
638c5f01b2fSopenharmony_ci                auto it = it_begin;
639c5f01b2fSopenharmony_ci                CHECK(it != it_end);
640c5f01b2fSopenharmony_ci                CHECK(*it == j[2]);
641c5f01b2fSopenharmony_ci
642c5f01b2fSopenharmony_ci                it++;
643c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
644c5f01b2fSopenharmony_ci                CHECK(it != it_end);
645c5f01b2fSopenharmony_ci                CHECK(*it == j[1]);
646c5f01b2fSopenharmony_ci
647c5f01b2fSopenharmony_ci                ++it;
648c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
649c5f01b2fSopenharmony_ci                CHECK(it != it_end);
650c5f01b2fSopenharmony_ci                CHECK(*it == j[0]);
651c5f01b2fSopenharmony_ci
652c5f01b2fSopenharmony_ci                ++it;
653c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
654c5f01b2fSopenharmony_ci                CHECK(it == it_end);
655c5f01b2fSopenharmony_ci            }
656c5f01b2fSopenharmony_ci
657c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
658c5f01b2fSopenharmony_ci            {
659c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_begin = j.crbegin();
660c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_end = j.crend();
661c5f01b2fSopenharmony_ci
662c5f01b2fSopenharmony_ci                auto it = it_begin;
663c5f01b2fSopenharmony_ci                CHECK(it != it_end);
664c5f01b2fSopenharmony_ci                CHECK(*it == j[2]);
665c5f01b2fSopenharmony_ci
666c5f01b2fSopenharmony_ci                it++;
667c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
668c5f01b2fSopenharmony_ci                CHECK(it != it_end);
669c5f01b2fSopenharmony_ci                CHECK(*it == j[1]);
670c5f01b2fSopenharmony_ci
671c5f01b2fSopenharmony_ci                ++it;
672c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
673c5f01b2fSopenharmony_ci                CHECK(it != it_end);
674c5f01b2fSopenharmony_ci                CHECK(*it == j[0]);
675c5f01b2fSopenharmony_ci
676c5f01b2fSopenharmony_ci                ++it;
677c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
678c5f01b2fSopenharmony_ci                CHECK(it == it_end);
679c5f01b2fSopenharmony_ci            }
680c5f01b2fSopenharmony_ci
681c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
682c5f01b2fSopenharmony_ci            {
683c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_begin = j_const.crbegin();
684c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_end = j_const.crend();
685c5f01b2fSopenharmony_ci
686c5f01b2fSopenharmony_ci                auto it = it_begin;
687c5f01b2fSopenharmony_ci                CHECK(it != it_end);
688c5f01b2fSopenharmony_ci                CHECK(*it == j[2]);
689c5f01b2fSopenharmony_ci
690c5f01b2fSopenharmony_ci                it++;
691c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
692c5f01b2fSopenharmony_ci                CHECK(it != it_end);
693c5f01b2fSopenharmony_ci                CHECK(*it == j[1]);
694c5f01b2fSopenharmony_ci
695c5f01b2fSopenharmony_ci                ++it;
696c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
697c5f01b2fSopenharmony_ci                CHECK(it != it_end);
698c5f01b2fSopenharmony_ci                CHECK(*it == j[0]);
699c5f01b2fSopenharmony_ci
700c5f01b2fSopenharmony_ci                ++it;
701c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
702c5f01b2fSopenharmony_ci                CHECK(it == it_end);
703c5f01b2fSopenharmony_ci            }
704c5f01b2fSopenharmony_ci
705c5f01b2fSopenharmony_ci            SECTION("key/value")
706c5f01b2fSopenharmony_ci            {
707c5f01b2fSopenharmony_ci                auto it = j.begin();
708c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
709c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
710c5f01b2fSopenharmony_ci                CHECK(it.value() == json(1));
711c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
712c5f01b2fSopenharmony_ci                CHECK(cit.value() == json(1));
713c5f01b2fSopenharmony_ci            }
714c5f01b2fSopenharmony_ci        }
715c5f01b2fSopenharmony_ci
716c5f01b2fSopenharmony_ci        SECTION("object")
717c5f01b2fSopenharmony_ci        {
718c5f01b2fSopenharmony_ci            json j = {{"A", 1}, {"B", 2}, {"C", 3}};
719c5f01b2fSopenharmony_ci            json j_const(j);
720c5f01b2fSopenharmony_ci
721c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
722c5f01b2fSopenharmony_ci            {
723c5f01b2fSopenharmony_ci                json::iterator it_begin = j.begin();
724c5f01b2fSopenharmony_ci                json::iterator it_end = j.end();
725c5f01b2fSopenharmony_ci
726c5f01b2fSopenharmony_ci                auto it = it_begin;
727c5f01b2fSopenharmony_ci                CHECK(it != it_end);
728c5f01b2fSopenharmony_ci                CHECK(*it == j["A"]);
729c5f01b2fSopenharmony_ci
730c5f01b2fSopenharmony_ci                it++;
731c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
732c5f01b2fSopenharmony_ci                CHECK(it != it_end);
733c5f01b2fSopenharmony_ci                CHECK(*it == j["B"]);
734c5f01b2fSopenharmony_ci
735c5f01b2fSopenharmony_ci                ++it;
736c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
737c5f01b2fSopenharmony_ci                CHECK(it != it_end);
738c5f01b2fSopenharmony_ci                CHECK(*it == j["C"]);
739c5f01b2fSopenharmony_ci
740c5f01b2fSopenharmony_ci                ++it;
741c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
742c5f01b2fSopenharmony_ci                CHECK(it == it_end);
743c5f01b2fSopenharmony_ci            }
744c5f01b2fSopenharmony_ci
745c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
746c5f01b2fSopenharmony_ci            {
747c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j_const.begin();
748c5f01b2fSopenharmony_ci                json::const_iterator it_end = j_const.end();
749c5f01b2fSopenharmony_ci
750c5f01b2fSopenharmony_ci                auto it = it_begin;
751c5f01b2fSopenharmony_ci                CHECK(it != it_end);
752c5f01b2fSopenharmony_ci                CHECK(*it == j_const["A"]);
753c5f01b2fSopenharmony_ci
754c5f01b2fSopenharmony_ci                it++;
755c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
756c5f01b2fSopenharmony_ci                CHECK(it != it_end);
757c5f01b2fSopenharmony_ci                CHECK(*it == j_const["B"]);
758c5f01b2fSopenharmony_ci
759c5f01b2fSopenharmony_ci                ++it;
760c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
761c5f01b2fSopenharmony_ci                CHECK(it != it_end);
762c5f01b2fSopenharmony_ci                CHECK(*it == j_const["C"]);
763c5f01b2fSopenharmony_ci
764c5f01b2fSopenharmony_ci                ++it;
765c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
766c5f01b2fSopenharmony_ci                CHECK(it == it_end);
767c5f01b2fSopenharmony_ci            }
768c5f01b2fSopenharmony_ci
769c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
770c5f01b2fSopenharmony_ci            {
771c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j.cbegin();
772c5f01b2fSopenharmony_ci                json::const_iterator it_end = j.cend();
773c5f01b2fSopenharmony_ci
774c5f01b2fSopenharmony_ci                auto it = it_begin;
775c5f01b2fSopenharmony_ci                CHECK(it != it_end);
776c5f01b2fSopenharmony_ci                CHECK(*it == j["A"]);
777c5f01b2fSopenharmony_ci
778c5f01b2fSopenharmony_ci                it++;
779c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
780c5f01b2fSopenharmony_ci                CHECK(it != it_end);
781c5f01b2fSopenharmony_ci                CHECK(*it == j["B"]);
782c5f01b2fSopenharmony_ci
783c5f01b2fSopenharmony_ci                ++it;
784c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
785c5f01b2fSopenharmony_ci                CHECK(it != it_end);
786c5f01b2fSopenharmony_ci                CHECK(*it == j["C"]);
787c5f01b2fSopenharmony_ci
788c5f01b2fSopenharmony_ci                ++it;
789c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
790c5f01b2fSopenharmony_ci                CHECK(it == it_end);
791c5f01b2fSopenharmony_ci            }
792c5f01b2fSopenharmony_ci
793c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
794c5f01b2fSopenharmony_ci            {
795c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j_const.cbegin();
796c5f01b2fSopenharmony_ci                json::const_iterator it_end = j_const.cend();
797c5f01b2fSopenharmony_ci
798c5f01b2fSopenharmony_ci                auto it = it_begin;
799c5f01b2fSopenharmony_ci                CHECK(it != it_end);
800c5f01b2fSopenharmony_ci                CHECK(*it == j_const["A"]);
801c5f01b2fSopenharmony_ci
802c5f01b2fSopenharmony_ci                it++;
803c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
804c5f01b2fSopenharmony_ci                CHECK(it != it_end);
805c5f01b2fSopenharmony_ci                CHECK(*it == j_const["B"]);
806c5f01b2fSopenharmony_ci
807c5f01b2fSopenharmony_ci                ++it;
808c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
809c5f01b2fSopenharmony_ci                CHECK(it != it_end);
810c5f01b2fSopenharmony_ci                CHECK(*it == j_const["C"]);
811c5f01b2fSopenharmony_ci
812c5f01b2fSopenharmony_ci                ++it;
813c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
814c5f01b2fSopenharmony_ci                CHECK(it == it_end);
815c5f01b2fSopenharmony_ci            }
816c5f01b2fSopenharmony_ci
817c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
818c5f01b2fSopenharmony_ci            {
819c5f01b2fSopenharmony_ci                json::reverse_iterator it_begin = j.rbegin();
820c5f01b2fSopenharmony_ci                json::reverse_iterator it_end = j.rend();
821c5f01b2fSopenharmony_ci
822c5f01b2fSopenharmony_ci                auto it = it_begin;
823c5f01b2fSopenharmony_ci                CHECK(it != it_end);
824c5f01b2fSopenharmony_ci                CHECK(*it == j["C"]);
825c5f01b2fSopenharmony_ci
826c5f01b2fSopenharmony_ci                it++;
827c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
828c5f01b2fSopenharmony_ci                CHECK(it != it_end);
829c5f01b2fSopenharmony_ci                CHECK(*it == j["B"]);
830c5f01b2fSopenharmony_ci
831c5f01b2fSopenharmony_ci                ++it;
832c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
833c5f01b2fSopenharmony_ci                CHECK(it != it_end);
834c5f01b2fSopenharmony_ci                CHECK(*it == j["A"]);
835c5f01b2fSopenharmony_ci
836c5f01b2fSopenharmony_ci                ++it;
837c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
838c5f01b2fSopenharmony_ci                CHECK(it == it_end);
839c5f01b2fSopenharmony_ci            }
840c5f01b2fSopenharmony_ci
841c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
842c5f01b2fSopenharmony_ci            {
843c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_begin = j.crbegin();
844c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_end = j.crend();
845c5f01b2fSopenharmony_ci
846c5f01b2fSopenharmony_ci                auto it = it_begin;
847c5f01b2fSopenharmony_ci                CHECK(it != it_end);
848c5f01b2fSopenharmony_ci                CHECK(*it == j["C"]);
849c5f01b2fSopenharmony_ci
850c5f01b2fSopenharmony_ci                it++;
851c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
852c5f01b2fSopenharmony_ci                CHECK(it != it_end);
853c5f01b2fSopenharmony_ci                CHECK(*it == j["B"]);
854c5f01b2fSopenharmony_ci
855c5f01b2fSopenharmony_ci                ++it;
856c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
857c5f01b2fSopenharmony_ci                CHECK(it != it_end);
858c5f01b2fSopenharmony_ci                CHECK(*it == j["A"]);
859c5f01b2fSopenharmony_ci
860c5f01b2fSopenharmony_ci                ++it;
861c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
862c5f01b2fSopenharmony_ci                CHECK(it == it_end);
863c5f01b2fSopenharmony_ci            }
864c5f01b2fSopenharmony_ci
865c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
866c5f01b2fSopenharmony_ci            {
867c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_begin = j_const.crbegin();
868c5f01b2fSopenharmony_ci                json::const_reverse_iterator it_end = j_const.crend();
869c5f01b2fSopenharmony_ci
870c5f01b2fSopenharmony_ci                auto it = it_begin;
871c5f01b2fSopenharmony_ci                CHECK(it != it_end);
872c5f01b2fSopenharmony_ci                CHECK(*it == j["C"]);
873c5f01b2fSopenharmony_ci
874c5f01b2fSopenharmony_ci                it++;
875c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
876c5f01b2fSopenharmony_ci                CHECK(it != it_end);
877c5f01b2fSopenharmony_ci                CHECK(*it == j["B"]);
878c5f01b2fSopenharmony_ci
879c5f01b2fSopenharmony_ci                ++it;
880c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
881c5f01b2fSopenharmony_ci                CHECK(it != it_end);
882c5f01b2fSopenharmony_ci                CHECK(*it == j["A"]);
883c5f01b2fSopenharmony_ci
884c5f01b2fSopenharmony_ci                ++it;
885c5f01b2fSopenharmony_ci                CHECK(it != it_begin);
886c5f01b2fSopenharmony_ci                CHECK(it == it_end);
887c5f01b2fSopenharmony_ci            }
888c5f01b2fSopenharmony_ci
889c5f01b2fSopenharmony_ci            SECTION("key/value")
890c5f01b2fSopenharmony_ci            {
891c5f01b2fSopenharmony_ci                auto it = j.begin();
892c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
893c5f01b2fSopenharmony_ci                CHECK(it.key() == "A");
894c5f01b2fSopenharmony_ci                CHECK(it.value() == json(1));
895c5f01b2fSopenharmony_ci                CHECK(cit.key() == "A");
896c5f01b2fSopenharmony_ci                CHECK(cit.value() == json(1));
897c5f01b2fSopenharmony_ci            }
898c5f01b2fSopenharmony_ci        }
899c5f01b2fSopenharmony_ci
900c5f01b2fSopenharmony_ci        SECTION("number (integer)")
901c5f01b2fSopenharmony_ci        {
902c5f01b2fSopenharmony_ci            json j = 23;
903c5f01b2fSopenharmony_ci            json j_const(j);
904c5f01b2fSopenharmony_ci
905c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
906c5f01b2fSopenharmony_ci            {
907c5f01b2fSopenharmony_ci                json::iterator it = j.begin();
908c5f01b2fSopenharmony_ci                CHECK(it != j.end());
909c5f01b2fSopenharmony_ci                CHECK(*it == j);
910c5f01b2fSopenharmony_ci
911c5f01b2fSopenharmony_ci                it++;
912c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
913c5f01b2fSopenharmony_ci                CHECK(it == j.end());
914c5f01b2fSopenharmony_ci
915c5f01b2fSopenharmony_ci                it--;
916c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
917c5f01b2fSopenharmony_ci                CHECK(it != j.end());
918c5f01b2fSopenharmony_ci                CHECK(*it == j);
919c5f01b2fSopenharmony_ci
920c5f01b2fSopenharmony_ci                ++it;
921c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
922c5f01b2fSopenharmony_ci                CHECK(it == j.end());
923c5f01b2fSopenharmony_ci
924c5f01b2fSopenharmony_ci                --it;
925c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
926c5f01b2fSopenharmony_ci                CHECK(it != j.end());
927c5f01b2fSopenharmony_ci                CHECK(*it == j);
928c5f01b2fSopenharmony_ci            }
929c5f01b2fSopenharmony_ci
930c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
931c5f01b2fSopenharmony_ci            {
932c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.begin();
933c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
934c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
935c5f01b2fSopenharmony_ci
936c5f01b2fSopenharmony_ci                it++;
937c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
938c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
939c5f01b2fSopenharmony_ci
940c5f01b2fSopenharmony_ci                it--;
941c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
942c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
943c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
944c5f01b2fSopenharmony_ci
945c5f01b2fSopenharmony_ci                ++it;
946c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
947c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
948c5f01b2fSopenharmony_ci
949c5f01b2fSopenharmony_ci                --it;
950c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
951c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
952c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
953c5f01b2fSopenharmony_ci            }
954c5f01b2fSopenharmony_ci
955c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
956c5f01b2fSopenharmony_ci            {
957c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
958c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
959c5f01b2fSopenharmony_ci                CHECK(*it == j);
960c5f01b2fSopenharmony_ci
961c5f01b2fSopenharmony_ci                it++;
962c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
963c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
964c5f01b2fSopenharmony_ci
965c5f01b2fSopenharmony_ci                it--;
966c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
967c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
968c5f01b2fSopenharmony_ci                CHECK(*it == j);
969c5f01b2fSopenharmony_ci
970c5f01b2fSopenharmony_ci                ++it;
971c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
972c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
973c5f01b2fSopenharmony_ci
974c5f01b2fSopenharmony_ci                --it;
975c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
976c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
977c5f01b2fSopenharmony_ci                CHECK(*it == j);
978c5f01b2fSopenharmony_ci            }
979c5f01b2fSopenharmony_ci
980c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
981c5f01b2fSopenharmony_ci            {
982c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.cbegin();
983c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
984c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
985c5f01b2fSopenharmony_ci
986c5f01b2fSopenharmony_ci                it++;
987c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
988c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
989c5f01b2fSopenharmony_ci
990c5f01b2fSopenharmony_ci                it--;
991c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
992c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
993c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
994c5f01b2fSopenharmony_ci
995c5f01b2fSopenharmony_ci                ++it;
996c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
997c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
998c5f01b2fSopenharmony_ci
999c5f01b2fSopenharmony_ci                --it;
1000c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
1001c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1002c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1003c5f01b2fSopenharmony_ci            }
1004c5f01b2fSopenharmony_ci
1005c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
1006c5f01b2fSopenharmony_ci            {
1007c5f01b2fSopenharmony_ci                json::reverse_iterator it = j.rbegin();
1008c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1009c5f01b2fSopenharmony_ci                CHECK(*it == j);
1010c5f01b2fSopenharmony_ci
1011c5f01b2fSopenharmony_ci                it++;
1012c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
1013c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1014c5f01b2fSopenharmony_ci
1015c5f01b2fSopenharmony_ci                it--;
1016c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
1017c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1018c5f01b2fSopenharmony_ci                CHECK(*it == j);
1019c5f01b2fSopenharmony_ci
1020c5f01b2fSopenharmony_ci                ++it;
1021c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
1022c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1023c5f01b2fSopenharmony_ci
1024c5f01b2fSopenharmony_ci                --it;
1025c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
1026c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1027c5f01b2fSopenharmony_ci                CHECK(*it == j);
1028c5f01b2fSopenharmony_ci            }
1029c5f01b2fSopenharmony_ci
1030c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
1031c5f01b2fSopenharmony_ci            {
1032c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j.crbegin();
1033c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1034c5f01b2fSopenharmony_ci                CHECK(*it == j);
1035c5f01b2fSopenharmony_ci
1036c5f01b2fSopenharmony_ci                it++;
1037c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
1038c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1039c5f01b2fSopenharmony_ci
1040c5f01b2fSopenharmony_ci                it--;
1041c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
1042c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1043c5f01b2fSopenharmony_ci                CHECK(*it == j);
1044c5f01b2fSopenharmony_ci
1045c5f01b2fSopenharmony_ci                ++it;
1046c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
1047c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1048c5f01b2fSopenharmony_ci
1049c5f01b2fSopenharmony_ci                --it;
1050c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
1051c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1052c5f01b2fSopenharmony_ci                CHECK(*it == j);
1053c5f01b2fSopenharmony_ci            }
1054c5f01b2fSopenharmony_ci
1055c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
1056c5f01b2fSopenharmony_ci            {
1057c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j_const.crbegin();
1058c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1059c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1060c5f01b2fSopenharmony_ci
1061c5f01b2fSopenharmony_ci                it++;
1062c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
1063c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1064c5f01b2fSopenharmony_ci
1065c5f01b2fSopenharmony_ci                it--;
1066c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
1067c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1068c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1069c5f01b2fSopenharmony_ci
1070c5f01b2fSopenharmony_ci                ++it;
1071c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
1072c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1073c5f01b2fSopenharmony_ci
1074c5f01b2fSopenharmony_ci                --it;
1075c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
1076c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1077c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1078c5f01b2fSopenharmony_ci            }
1079c5f01b2fSopenharmony_ci
1080c5f01b2fSopenharmony_ci            SECTION("key/value")
1081c5f01b2fSopenharmony_ci            {
1082c5f01b2fSopenharmony_ci                auto it = j.begin();
1083c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
1084c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1085c5f01b2fSopenharmony_ci                CHECK(it.value() == json(23));
1086c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1087c5f01b2fSopenharmony_ci                CHECK(cit.value() == json(23));
1088c5f01b2fSopenharmony_ci
1089c5f01b2fSopenharmony_ci                auto rit = j.rend();
1090c5f01b2fSopenharmony_ci                auto crit = j.crend();
1091c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1092c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1093c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1094c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1095c5f01b2fSopenharmony_ci            }
1096c5f01b2fSopenharmony_ci        }
1097c5f01b2fSopenharmony_ci
1098c5f01b2fSopenharmony_ci        SECTION("number (unsigned)")
1099c5f01b2fSopenharmony_ci        {
1100c5f01b2fSopenharmony_ci            json j = 23u;
1101c5f01b2fSopenharmony_ci            json j_const(j);
1102c5f01b2fSopenharmony_ci
1103c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
1104c5f01b2fSopenharmony_ci            {
1105c5f01b2fSopenharmony_ci                json::iterator it = j.begin();
1106c5f01b2fSopenharmony_ci                CHECK(it != j.end());
1107c5f01b2fSopenharmony_ci                CHECK(*it == j);
1108c5f01b2fSopenharmony_ci
1109c5f01b2fSopenharmony_ci                it++;
1110c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
1111c5f01b2fSopenharmony_ci                CHECK(it == j.end());
1112c5f01b2fSopenharmony_ci
1113c5f01b2fSopenharmony_ci                it--;
1114c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
1115c5f01b2fSopenharmony_ci                CHECK(it != j.end());
1116c5f01b2fSopenharmony_ci                CHECK(*it == j);
1117c5f01b2fSopenharmony_ci
1118c5f01b2fSopenharmony_ci                ++it;
1119c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
1120c5f01b2fSopenharmony_ci                CHECK(it == j.end());
1121c5f01b2fSopenharmony_ci
1122c5f01b2fSopenharmony_ci                --it;
1123c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
1124c5f01b2fSopenharmony_ci                CHECK(it != j.end());
1125c5f01b2fSopenharmony_ci                CHECK(*it == j);
1126c5f01b2fSopenharmony_ci            }
1127c5f01b2fSopenharmony_ci
1128c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
1129c5f01b2fSopenharmony_ci            {
1130c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.begin();
1131c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
1132c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1133c5f01b2fSopenharmony_ci
1134c5f01b2fSopenharmony_ci                it++;
1135c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
1136c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
1137c5f01b2fSopenharmony_ci
1138c5f01b2fSopenharmony_ci                it--;
1139c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
1140c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
1141c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1142c5f01b2fSopenharmony_ci
1143c5f01b2fSopenharmony_ci                ++it;
1144c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
1145c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
1146c5f01b2fSopenharmony_ci
1147c5f01b2fSopenharmony_ci                --it;
1148c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
1149c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
1150c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1151c5f01b2fSopenharmony_ci            }
1152c5f01b2fSopenharmony_ci
1153c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
1154c5f01b2fSopenharmony_ci            {
1155c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
1156c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
1157c5f01b2fSopenharmony_ci                CHECK(*it == j);
1158c5f01b2fSopenharmony_ci
1159c5f01b2fSopenharmony_ci                it++;
1160c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
1161c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
1162c5f01b2fSopenharmony_ci
1163c5f01b2fSopenharmony_ci                it--;
1164c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
1165c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
1166c5f01b2fSopenharmony_ci                CHECK(*it == j);
1167c5f01b2fSopenharmony_ci
1168c5f01b2fSopenharmony_ci                ++it;
1169c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
1170c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
1171c5f01b2fSopenharmony_ci
1172c5f01b2fSopenharmony_ci                --it;
1173c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
1174c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
1175c5f01b2fSopenharmony_ci                CHECK(*it == j);
1176c5f01b2fSopenharmony_ci            }
1177c5f01b2fSopenharmony_ci
1178c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
1179c5f01b2fSopenharmony_ci            {
1180c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.cbegin();
1181c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1182c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1183c5f01b2fSopenharmony_ci
1184c5f01b2fSopenharmony_ci                it++;
1185c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
1186c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
1187c5f01b2fSopenharmony_ci
1188c5f01b2fSopenharmony_ci                it--;
1189c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
1190c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1191c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1192c5f01b2fSopenharmony_ci
1193c5f01b2fSopenharmony_ci                ++it;
1194c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
1195c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
1196c5f01b2fSopenharmony_ci
1197c5f01b2fSopenharmony_ci                --it;
1198c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
1199c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1200c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1201c5f01b2fSopenharmony_ci            }
1202c5f01b2fSopenharmony_ci
1203c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
1204c5f01b2fSopenharmony_ci            {
1205c5f01b2fSopenharmony_ci                json::reverse_iterator it = j.rbegin();
1206c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1207c5f01b2fSopenharmony_ci                CHECK(*it == j);
1208c5f01b2fSopenharmony_ci
1209c5f01b2fSopenharmony_ci                it++;
1210c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
1211c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1212c5f01b2fSopenharmony_ci
1213c5f01b2fSopenharmony_ci                it--;
1214c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
1215c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1216c5f01b2fSopenharmony_ci                CHECK(*it == j);
1217c5f01b2fSopenharmony_ci
1218c5f01b2fSopenharmony_ci                ++it;
1219c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
1220c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1221c5f01b2fSopenharmony_ci
1222c5f01b2fSopenharmony_ci                --it;
1223c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
1224c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1225c5f01b2fSopenharmony_ci                CHECK(*it == j);
1226c5f01b2fSopenharmony_ci            }
1227c5f01b2fSopenharmony_ci
1228c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
1229c5f01b2fSopenharmony_ci            {
1230c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j.crbegin();
1231c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1232c5f01b2fSopenharmony_ci                CHECK(*it == j);
1233c5f01b2fSopenharmony_ci
1234c5f01b2fSopenharmony_ci                it++;
1235c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
1236c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1237c5f01b2fSopenharmony_ci
1238c5f01b2fSopenharmony_ci                it--;
1239c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
1240c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1241c5f01b2fSopenharmony_ci                CHECK(*it == j);
1242c5f01b2fSopenharmony_ci
1243c5f01b2fSopenharmony_ci                ++it;
1244c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
1245c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1246c5f01b2fSopenharmony_ci
1247c5f01b2fSopenharmony_ci                --it;
1248c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
1249c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1250c5f01b2fSopenharmony_ci                CHECK(*it == j);
1251c5f01b2fSopenharmony_ci            }
1252c5f01b2fSopenharmony_ci
1253c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
1254c5f01b2fSopenharmony_ci            {
1255c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j_const.crbegin();
1256c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1257c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1258c5f01b2fSopenharmony_ci
1259c5f01b2fSopenharmony_ci                it++;
1260c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
1261c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1262c5f01b2fSopenharmony_ci
1263c5f01b2fSopenharmony_ci                it--;
1264c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
1265c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1266c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1267c5f01b2fSopenharmony_ci
1268c5f01b2fSopenharmony_ci                ++it;
1269c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
1270c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1271c5f01b2fSopenharmony_ci
1272c5f01b2fSopenharmony_ci                --it;
1273c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
1274c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1275c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1276c5f01b2fSopenharmony_ci            }
1277c5f01b2fSopenharmony_ci
1278c5f01b2fSopenharmony_ci            SECTION("key/value")
1279c5f01b2fSopenharmony_ci            {
1280c5f01b2fSopenharmony_ci                auto it = j.begin();
1281c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
1282c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1283c5f01b2fSopenharmony_ci                CHECK(it.value() == json(23));
1284c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1285c5f01b2fSopenharmony_ci                CHECK(cit.value() == json(23));
1286c5f01b2fSopenharmony_ci
1287c5f01b2fSopenharmony_ci                auto rit = j.rend();
1288c5f01b2fSopenharmony_ci                auto crit = j.crend();
1289c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1290c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1291c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1292c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1293c5f01b2fSopenharmony_ci            }
1294c5f01b2fSopenharmony_ci        }
1295c5f01b2fSopenharmony_ci
1296c5f01b2fSopenharmony_ci        SECTION("number (float)")
1297c5f01b2fSopenharmony_ci        {
1298c5f01b2fSopenharmony_ci            json j = 23.42;
1299c5f01b2fSopenharmony_ci            json j_const(j);
1300c5f01b2fSopenharmony_ci
1301c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
1302c5f01b2fSopenharmony_ci            {
1303c5f01b2fSopenharmony_ci                json::iterator it = j.begin();
1304c5f01b2fSopenharmony_ci                CHECK(it != j.end());
1305c5f01b2fSopenharmony_ci                CHECK(*it == j);
1306c5f01b2fSopenharmony_ci
1307c5f01b2fSopenharmony_ci                it++;
1308c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
1309c5f01b2fSopenharmony_ci                CHECK(it == j.end());
1310c5f01b2fSopenharmony_ci
1311c5f01b2fSopenharmony_ci                it--;
1312c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
1313c5f01b2fSopenharmony_ci                CHECK(it != j.end());
1314c5f01b2fSopenharmony_ci                CHECK(*it == j);
1315c5f01b2fSopenharmony_ci
1316c5f01b2fSopenharmony_ci                ++it;
1317c5f01b2fSopenharmony_ci                CHECK(it != j.begin());
1318c5f01b2fSopenharmony_ci                CHECK(it == j.end());
1319c5f01b2fSopenharmony_ci
1320c5f01b2fSopenharmony_ci                --it;
1321c5f01b2fSopenharmony_ci                CHECK(it == j.begin());
1322c5f01b2fSopenharmony_ci                CHECK(it != j.end());
1323c5f01b2fSopenharmony_ci                CHECK(*it == j);
1324c5f01b2fSopenharmony_ci            }
1325c5f01b2fSopenharmony_ci
1326c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
1327c5f01b2fSopenharmony_ci            {
1328c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.begin();
1329c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
1330c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1331c5f01b2fSopenharmony_ci
1332c5f01b2fSopenharmony_ci                it++;
1333c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
1334c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
1335c5f01b2fSopenharmony_ci
1336c5f01b2fSopenharmony_ci                it--;
1337c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
1338c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
1339c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1340c5f01b2fSopenharmony_ci
1341c5f01b2fSopenharmony_ci                ++it;
1342c5f01b2fSopenharmony_ci                CHECK(it != j_const.begin());
1343c5f01b2fSopenharmony_ci                CHECK(it == j_const.end());
1344c5f01b2fSopenharmony_ci
1345c5f01b2fSopenharmony_ci                --it;
1346c5f01b2fSopenharmony_ci                CHECK(it == j_const.begin());
1347c5f01b2fSopenharmony_ci                CHECK(it != j_const.end());
1348c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1349c5f01b2fSopenharmony_ci            }
1350c5f01b2fSopenharmony_ci
1351c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
1352c5f01b2fSopenharmony_ci            {
1353c5f01b2fSopenharmony_ci                json::const_iterator it = j.cbegin();
1354c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
1355c5f01b2fSopenharmony_ci                CHECK(*it == j);
1356c5f01b2fSopenharmony_ci
1357c5f01b2fSopenharmony_ci                it++;
1358c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
1359c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
1360c5f01b2fSopenharmony_ci
1361c5f01b2fSopenharmony_ci                it--;
1362c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
1363c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
1364c5f01b2fSopenharmony_ci                CHECK(*it == j);
1365c5f01b2fSopenharmony_ci
1366c5f01b2fSopenharmony_ci                ++it;
1367c5f01b2fSopenharmony_ci                CHECK(it != j.cbegin());
1368c5f01b2fSopenharmony_ci                CHECK(it == j.cend());
1369c5f01b2fSopenharmony_ci
1370c5f01b2fSopenharmony_ci                --it;
1371c5f01b2fSopenharmony_ci                CHECK(it == j.cbegin());
1372c5f01b2fSopenharmony_ci                CHECK(it != j.cend());
1373c5f01b2fSopenharmony_ci                CHECK(*it == j);
1374c5f01b2fSopenharmony_ci            }
1375c5f01b2fSopenharmony_ci
1376c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
1377c5f01b2fSopenharmony_ci            {
1378c5f01b2fSopenharmony_ci                json::const_iterator it = j_const.cbegin();
1379c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1380c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1381c5f01b2fSopenharmony_ci
1382c5f01b2fSopenharmony_ci                it++;
1383c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
1384c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
1385c5f01b2fSopenharmony_ci
1386c5f01b2fSopenharmony_ci                it--;
1387c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
1388c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1389c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1390c5f01b2fSopenharmony_ci
1391c5f01b2fSopenharmony_ci                ++it;
1392c5f01b2fSopenharmony_ci                CHECK(it != j_const.cbegin());
1393c5f01b2fSopenharmony_ci                CHECK(it == j_const.cend());
1394c5f01b2fSopenharmony_ci
1395c5f01b2fSopenharmony_ci                --it;
1396c5f01b2fSopenharmony_ci                CHECK(it == j_const.cbegin());
1397c5f01b2fSopenharmony_ci                CHECK(it != j_const.cend());
1398c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1399c5f01b2fSopenharmony_ci            }
1400c5f01b2fSopenharmony_ci
1401c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
1402c5f01b2fSopenharmony_ci            {
1403c5f01b2fSopenharmony_ci                json::reverse_iterator it = j.rbegin();
1404c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1405c5f01b2fSopenharmony_ci                CHECK(*it == j);
1406c5f01b2fSopenharmony_ci
1407c5f01b2fSopenharmony_ci                it++;
1408c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
1409c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1410c5f01b2fSopenharmony_ci
1411c5f01b2fSopenharmony_ci                it--;
1412c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
1413c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1414c5f01b2fSopenharmony_ci                CHECK(*it == j);
1415c5f01b2fSopenharmony_ci
1416c5f01b2fSopenharmony_ci                ++it;
1417c5f01b2fSopenharmony_ci                CHECK(it != j.rbegin());
1418c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1419c5f01b2fSopenharmony_ci
1420c5f01b2fSopenharmony_ci                --it;
1421c5f01b2fSopenharmony_ci                CHECK(it == j.rbegin());
1422c5f01b2fSopenharmony_ci                CHECK(it != j.rend());
1423c5f01b2fSopenharmony_ci                CHECK(*it == j);
1424c5f01b2fSopenharmony_ci            }
1425c5f01b2fSopenharmony_ci
1426c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
1427c5f01b2fSopenharmony_ci            {
1428c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j.crbegin();
1429c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1430c5f01b2fSopenharmony_ci                CHECK(*it == j);
1431c5f01b2fSopenharmony_ci
1432c5f01b2fSopenharmony_ci                it++;
1433c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
1434c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1435c5f01b2fSopenharmony_ci
1436c5f01b2fSopenharmony_ci                it--;
1437c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
1438c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1439c5f01b2fSopenharmony_ci                CHECK(*it == j);
1440c5f01b2fSopenharmony_ci
1441c5f01b2fSopenharmony_ci                ++it;
1442c5f01b2fSopenharmony_ci                CHECK(it != j.crbegin());
1443c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1444c5f01b2fSopenharmony_ci
1445c5f01b2fSopenharmony_ci                --it;
1446c5f01b2fSopenharmony_ci                CHECK(it == j.crbegin());
1447c5f01b2fSopenharmony_ci                CHECK(it != j.crend());
1448c5f01b2fSopenharmony_ci                CHECK(*it == j);
1449c5f01b2fSopenharmony_ci            }
1450c5f01b2fSopenharmony_ci
1451c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
1452c5f01b2fSopenharmony_ci            {
1453c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j_const.crbegin();
1454c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1455c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1456c5f01b2fSopenharmony_ci
1457c5f01b2fSopenharmony_ci                it++;
1458c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
1459c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1460c5f01b2fSopenharmony_ci
1461c5f01b2fSopenharmony_ci                it--;
1462c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
1463c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1464c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1465c5f01b2fSopenharmony_ci
1466c5f01b2fSopenharmony_ci                ++it;
1467c5f01b2fSopenharmony_ci                CHECK(it != j_const.crbegin());
1468c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1469c5f01b2fSopenharmony_ci
1470c5f01b2fSopenharmony_ci                --it;
1471c5f01b2fSopenharmony_ci                CHECK(it == j_const.crbegin());
1472c5f01b2fSopenharmony_ci                CHECK(it != j_const.crend());
1473c5f01b2fSopenharmony_ci                CHECK(*it == j_const);
1474c5f01b2fSopenharmony_ci            }
1475c5f01b2fSopenharmony_ci
1476c5f01b2fSopenharmony_ci            SECTION("key/value")
1477c5f01b2fSopenharmony_ci            {
1478c5f01b2fSopenharmony_ci                auto it = j.begin();
1479c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
1480c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1481c5f01b2fSopenharmony_ci                CHECK(it.value() == json(23.42));
1482c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1483c5f01b2fSopenharmony_ci                CHECK(cit.value() == json(23.42));
1484c5f01b2fSopenharmony_ci
1485c5f01b2fSopenharmony_ci                auto rit = j.rend();
1486c5f01b2fSopenharmony_ci                auto crit = j.crend();
1487c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1488c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1489c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1490c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1491c5f01b2fSopenharmony_ci            }
1492c5f01b2fSopenharmony_ci        }
1493c5f01b2fSopenharmony_ci
1494c5f01b2fSopenharmony_ci        SECTION("null")
1495c5f01b2fSopenharmony_ci        {
1496c5f01b2fSopenharmony_ci            json j = nullptr;
1497c5f01b2fSopenharmony_ci            json j_const(j);
1498c5f01b2fSopenharmony_ci
1499c5f01b2fSopenharmony_ci            SECTION("json + begin/end")
1500c5f01b2fSopenharmony_ci            {
1501c5f01b2fSopenharmony_ci                json::iterator it = j.begin();
1502c5f01b2fSopenharmony_ci                CHECK(it == j.end());
1503c5f01b2fSopenharmony_ci            }
1504c5f01b2fSopenharmony_ci
1505c5f01b2fSopenharmony_ci            SECTION("const json + begin/end")
1506c5f01b2fSopenharmony_ci            {
1507c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j_const.begin();
1508c5f01b2fSopenharmony_ci                json::const_iterator it_end = j_const.end();
1509c5f01b2fSopenharmony_ci                CHECK(it_begin == it_end);
1510c5f01b2fSopenharmony_ci            }
1511c5f01b2fSopenharmony_ci
1512c5f01b2fSopenharmony_ci            SECTION("json + cbegin/cend")
1513c5f01b2fSopenharmony_ci            {
1514c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j.cbegin();
1515c5f01b2fSopenharmony_ci                json::const_iterator it_end = j.cend();
1516c5f01b2fSopenharmony_ci                CHECK(it_begin == it_end);
1517c5f01b2fSopenharmony_ci            }
1518c5f01b2fSopenharmony_ci
1519c5f01b2fSopenharmony_ci            SECTION("const json + cbegin/cend")
1520c5f01b2fSopenharmony_ci            {
1521c5f01b2fSopenharmony_ci                json::const_iterator it_begin = j_const.cbegin();
1522c5f01b2fSopenharmony_ci                json::const_iterator it_end = j_const.cend();
1523c5f01b2fSopenharmony_ci                CHECK(it_begin == it_end);
1524c5f01b2fSopenharmony_ci            }
1525c5f01b2fSopenharmony_ci
1526c5f01b2fSopenharmony_ci            SECTION("json + rbegin/rend")
1527c5f01b2fSopenharmony_ci            {
1528c5f01b2fSopenharmony_ci                json::reverse_iterator it = j.rbegin();
1529c5f01b2fSopenharmony_ci                CHECK(it == j.rend());
1530c5f01b2fSopenharmony_ci            }
1531c5f01b2fSopenharmony_ci
1532c5f01b2fSopenharmony_ci            SECTION("json + crbegin/crend")
1533c5f01b2fSopenharmony_ci            {
1534c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j.crbegin();
1535c5f01b2fSopenharmony_ci                CHECK(it == j.crend());
1536c5f01b2fSopenharmony_ci            }
1537c5f01b2fSopenharmony_ci
1538c5f01b2fSopenharmony_ci            SECTION("const json + crbegin/crend")
1539c5f01b2fSopenharmony_ci            {
1540c5f01b2fSopenharmony_ci                json::const_reverse_iterator it = j_const.crbegin();
1541c5f01b2fSopenharmony_ci                CHECK(it == j_const.crend());
1542c5f01b2fSopenharmony_ci            }
1543c5f01b2fSopenharmony_ci
1544c5f01b2fSopenharmony_ci            SECTION("key/value")
1545c5f01b2fSopenharmony_ci            {
1546c5f01b2fSopenharmony_ci                auto it = j.begin();
1547c5f01b2fSopenharmony_ci                auto cit = j_const.cbegin();
1548c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1549c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(it.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1550c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1551c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(cit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1552c5f01b2fSopenharmony_ci
1553c5f01b2fSopenharmony_ci                auto rit = j.rend();
1554c5f01b2fSopenharmony_ci                auto crit = j.crend();
1555c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1556c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1557c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators", json::invalid_iterator&);
1558c5f01b2fSopenharmony_ci                CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&);
1559c5f01b2fSopenharmony_ci            }
1560c5f01b2fSopenharmony_ci        }
1561c5f01b2fSopenharmony_ci    }
1562c5f01b2fSopenharmony_ci
1563c5f01b2fSopenharmony_ci    SECTION("conversion from iterator to const iterator")
1564c5f01b2fSopenharmony_ci    {
1565c5f01b2fSopenharmony_ci        SECTION("boolean")
1566c5f01b2fSopenharmony_ci        {
1567c5f01b2fSopenharmony_ci            json j = true;
1568c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1569c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1570c5f01b2fSopenharmony_ci            it = j.begin();
1571c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1572c5f01b2fSopenharmony_ci        }
1573c5f01b2fSopenharmony_ci        SECTION("string")
1574c5f01b2fSopenharmony_ci        {
1575c5f01b2fSopenharmony_ci            json j = "hello world";
1576c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1577c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1578c5f01b2fSopenharmony_ci            it = j.begin();
1579c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1580c5f01b2fSopenharmony_ci        }
1581c5f01b2fSopenharmony_ci        SECTION("array")
1582c5f01b2fSopenharmony_ci        {
1583c5f01b2fSopenharmony_ci            json j = {1, 2, 3};
1584c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1585c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1586c5f01b2fSopenharmony_ci            it = j.begin();
1587c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1588c5f01b2fSopenharmony_ci        }
1589c5f01b2fSopenharmony_ci        SECTION("object")
1590c5f01b2fSopenharmony_ci        {
1591c5f01b2fSopenharmony_ci            json j = {{"A", 1}, {"B", 2}, {"C", 3}};
1592c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1593c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1594c5f01b2fSopenharmony_ci            it = j.begin();
1595c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1596c5f01b2fSopenharmony_ci        }
1597c5f01b2fSopenharmony_ci        SECTION("number (integer)")
1598c5f01b2fSopenharmony_ci        {
1599c5f01b2fSopenharmony_ci            json j = 23;
1600c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1601c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1602c5f01b2fSopenharmony_ci            it = j.begin();
1603c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1604c5f01b2fSopenharmony_ci        }
1605c5f01b2fSopenharmony_ci        SECTION("number (unsigned)")
1606c5f01b2fSopenharmony_ci        {
1607c5f01b2fSopenharmony_ci            json j = 23u;
1608c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1609c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1610c5f01b2fSopenharmony_ci            it = j.begin();
1611c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1612c5f01b2fSopenharmony_ci        }
1613c5f01b2fSopenharmony_ci        SECTION("number (float)")
1614c5f01b2fSopenharmony_ci        {
1615c5f01b2fSopenharmony_ci            json j = 23.42;
1616c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1617c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1618c5f01b2fSopenharmony_ci            it = j.begin();
1619c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1620c5f01b2fSopenharmony_ci        }
1621c5f01b2fSopenharmony_ci        SECTION("null")
1622c5f01b2fSopenharmony_ci        {
1623c5f01b2fSopenharmony_ci            json j = nullptr;
1624c5f01b2fSopenharmony_ci            json::const_iterator it = j.begin();
1625c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1626c5f01b2fSopenharmony_ci            it = j.begin();
1627c5f01b2fSopenharmony_ci            CHECK(it == j.cbegin());
1628c5f01b2fSopenharmony_ci        }
1629c5f01b2fSopenharmony_ci    }
1630c5f01b2fSopenharmony_ci}
1631