Skip to content

Commit eb0a3fc

Browse files
committed
csv cursor tests
1 parent 5522e3b commit eb0a3fc

File tree

9 files changed

+288
-289
lines changed

9 files changed

+288
-289
lines changed

include/jsoncons_ext/csv/csv_cursor.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ class basic_csv_cursor : public basic_staj_cursor<CharT>, private virtual ser_co
229229
{
230230
read_next(visitor, ec);
231231
}
232+
read_next(ec);
232233
}
233234

234235
void next() override

test/bson/src/bson_cursor_tests.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,39 @@ TEST_CASE("bson_cursor reputon test")
4141
{
4242
bson::bson_bytes_cursor cursor(data);
4343

44-
CHECK(cursor.current().event_type() == staj_event_type::begin_object);
44+
CHECK(staj_event_type::begin_object == cursor.current().event_type());
4545
cursor.next();
46-
CHECK(cursor.current().event_type() == staj_event_type::key);
46+
CHECK(staj_event_type::key == cursor.current().event_type());
4747
cursor.next();
48-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
48+
CHECK(staj_event_type::string_value == cursor.current().event_type());
4949
cursor.next();
50-
CHECK(cursor.current().event_type() == staj_event_type::key);
50+
CHECK(staj_event_type::key == cursor.current().event_type());
5151
cursor.next();
52-
CHECK(cursor.current().event_type() == staj_event_type::begin_array);
52+
CHECK(staj_event_type::begin_array == cursor.current().event_type());
5353
cursor.next();
54-
CHECK(cursor.current().event_type() == staj_event_type::begin_object);
54+
CHECK(staj_event_type::begin_object == cursor.current().event_type());
5555
cursor.next();
56-
CHECK(cursor.current().event_type() == staj_event_type::key);
56+
CHECK(staj_event_type::key == cursor.current().event_type());
5757
cursor.next();
58-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
58+
CHECK(staj_event_type::string_value == cursor.current().event_type());
5959
cursor.next();
60-
CHECK(cursor.current().event_type() == staj_event_type::key);
60+
CHECK(staj_event_type::key == cursor.current().event_type());
6161
cursor.next();
62-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
62+
CHECK(staj_event_type::string_value == cursor.current().event_type());
6363
cursor.next();
64-
CHECK(cursor.current().event_type() == staj_event_type::key);
64+
CHECK(staj_event_type::key == cursor.current().event_type());
6565
cursor.next();
66-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
66+
CHECK(staj_event_type::string_value == cursor.current().event_type());
6767
cursor.next();
68-
CHECK(cursor.current().event_type() == staj_event_type::key);
68+
CHECK(staj_event_type::key == cursor.current().event_type());
6969
cursor.next();
70-
CHECK(cursor.current().event_type() == staj_event_type::double_value);
70+
CHECK(staj_event_type::double_value == cursor.current().event_type());
7171
cursor.next();
72-
CHECK(cursor.current().event_type() == staj_event_type::end_object);
72+
CHECK(staj_event_type::end_object == cursor.current().event_type());
7373
cursor.next();
74-
CHECK(cursor.current().event_type() == staj_event_type::end_array);
74+
CHECK(staj_event_type::end_array == cursor.current().event_type());
7575
cursor.next();
76-
CHECK(cursor.current().event_type() == staj_event_type::end_object);
76+
CHECK(staj_event_type::end_object == cursor.current().event_type());
7777
cursor.next();
7878
CHECK(cursor.done());
7979
}
@@ -172,26 +172,26 @@ void check_bson_cursor_document(std::string info, CursorType& cursor,
172172
INFO(info);
173173

174174
REQUIRE_FALSE(cursor.done());
175-
CHECK(cursor.current().event_type() == staj_event_type::begin_object);
176-
CHECK(cursor.current().tag() == semantic_tag::none);
175+
CHECK(staj_event_type::begin_object == cursor.current().event_type());
176+
CHECK(semantic_tag::none == cursor.current().tag());
177177

178178
REQUIRE_FALSE(cursor.done());
179179
cursor.next();
180-
CHECK(cursor.current().event_type() == staj_event_type::key);
181-
CHECK(cursor.current().tag() == semantic_tag::none);
182-
CHECK(cursor.current().template get<std::string>() == expectedKey);
183-
CHECK(cursor.current().template get<jsoncons::string_view>() == expectedKey);
180+
CHECK(staj_event_type::key == cursor.current().event_type());
181+
CHECK(semantic_tag::none == cursor.current().tag());
182+
CHECK(expectedKey == cursor.current().template get<std::string>());
183+
CHECK(expectedKey == cursor.current().template get<jsoncons::string_view>());
184184

185185
REQUIRE_FALSE(cursor.done());
186186
cursor.next();
187-
CHECK(cursor.current().event_type() == staj_event_type::int64_value);
188-
CHECK(cursor.current().tag() == semantic_tag::none);
189-
CHECK(cursor.current().template get<int>() == expectedValue);
187+
CHECK(staj_event_type::int64_value == cursor.current().event_type());
188+
CHECK(semantic_tag::none == cursor.current().tag());
189+
CHECK(expectedValue == cursor.current().template get<int>());
190190

191191
REQUIRE_FALSE(cursor.done());
192192
cursor.next();
193-
CHECK(cursor.current().event_type() == staj_event_type::end_object);
194-
CHECK(cursor.current().tag() == semantic_tag::none);
193+
CHECK(staj_event_type::end_object == cursor.current().event_type());
194+
CHECK(semantic_tag::none == cursor.current().tag());
195195

196196
// Extra next() required to pop out of document state
197197
CHECK_FALSE(cursor.done());
@@ -283,15 +283,15 @@ TEMPLATE_TEST_CASE("bson_cursor reset test", "",
283283
cursor.reset(input2, ec);
284284
REQUIRE_FALSE(ec);
285285
REQUIRE_FALSE(cursor.done());
286-
CHECK(cursor.current().event_type() == staj_event_type::begin_object);
287-
CHECK(cursor.current().tag() == semantic_tag::none);
286+
CHECK(staj_event_type::begin_object == cursor.current().event_type());
287+
CHECK(semantic_tag::none == cursor.current().tag());
288288
REQUIRE_FALSE(cursor.done());
289289
cursor.next(ec);
290290
REQUIRE_FALSE(ec);
291291
REQUIRE_FALSE(cursor.done());
292-
CHECK(cursor.current().event_type() == staj_event_type::key);
293-
CHECK(cursor.current().tag() == semantic_tag::none);
294-
CHECK(cursor.current().template get<std::string>() == std::string("b"));
292+
CHECK(staj_event_type::key == cursor.current().event_type());
293+
CHECK(semantic_tag::none == cursor.current().tag());
294+
CHECK(std::string("b") == cursor.current().template get<std::string>());
295295
CHECK(cursor.current().template get<jsoncons::string_view>() ==
296296
jsoncons::string_view("b"));
297297
cursor.next(ec);

test/cbor/src/cbor_cursor_tests.cpp

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -42,41 +42,41 @@ TEST_CASE("cbor_cursor reputon test")
4242
{
4343
cbor::cbor_bytes_cursor cursor(data);
4444

45-
CHECK(cursor.current().event_type() == staj_event_type::begin_object);
46-
CHECK(cursor.current().size() == 2);
45+
CHECK(staj_event_type::begin_object == cursor.current().event_type());
46+
CHECK(2 == cursor.current().size());
4747
cursor.next();
48-
CHECK(cursor.current().event_type() == staj_event_type::key);
48+
CHECK(staj_event_type::key == cursor.current().event_type());
4949
cursor.next();
50-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
50+
CHECK(staj_event_type::string_value == cursor.current().event_type());
5151
cursor.next();
52-
CHECK(cursor.current().event_type() == staj_event_type::key);
52+
CHECK(staj_event_type::key == cursor.current().event_type());
5353
cursor.next();
54-
CHECK(cursor.current().event_type() == staj_event_type::begin_array);
55-
CHECK(cursor.current().size() == 1);
54+
CHECK(staj_event_type::begin_array == cursor.current().event_type());
55+
CHECK(1 == cursor.current().size());
5656
cursor.next();
57-
CHECK(cursor.current().event_type() == staj_event_type::begin_object);
57+
CHECK(staj_event_type::begin_object == cursor.current().event_type());
5858
cursor.next();
59-
CHECK(cursor.current().event_type() == staj_event_type::key);
59+
CHECK(staj_event_type::key == cursor.current().event_type());
6060
cursor.next();
61-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
61+
CHECK(staj_event_type::string_value == cursor.current().event_type());
6262
cursor.next();
63-
CHECK(cursor.current().event_type() == staj_event_type::key);
63+
CHECK(staj_event_type::key == cursor.current().event_type());
6464
cursor.next();
65-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
65+
CHECK(staj_event_type::string_value == cursor.current().event_type());
6666
cursor.next();
67-
CHECK(cursor.current().event_type() == staj_event_type::key);
67+
CHECK(staj_event_type::key == cursor.current().event_type());
6868
cursor.next();
69-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
69+
CHECK(staj_event_type::string_value == cursor.current().event_type());
7070
cursor.next();
71-
CHECK(cursor.current().event_type() == staj_event_type::key);
71+
CHECK(staj_event_type::key == cursor.current().event_type());
7272
cursor.next();
73-
CHECK(cursor.current().event_type() == staj_event_type::double_value);
73+
CHECK(staj_event_type::double_value == cursor.current().event_type());
7474
cursor.next();
75-
CHECK(cursor.current().event_type() == staj_event_type::end_object);
75+
CHECK(staj_event_type::end_object == cursor.current().event_type());
7676
cursor.next();
77-
CHECK(cursor.current().event_type() == staj_event_type::end_array);
77+
CHECK(staj_event_type::end_array == cursor.current().event_type());
7878
cursor.next();
79-
CHECK(cursor.current().event_type() == staj_event_type::end_object);
79+
CHECK(staj_event_type::end_object == cursor.current().event_type());
8080
cursor.next();
8181
CHECK(cursor.done());
8282
}
@@ -89,41 +89,41 @@ TEST_CASE("cbor_cursor indefinite array of array test")
8989
SECTION("test 1")
9090
{
9191
cbor::cbor_bytes_cursor cursor(data);
92-
CHECK(cursor.current().event_type() == staj_event_type::begin_array);
93-
CHECK(cursor.current().tag() == semantic_tag::none);
92+
CHECK(staj_event_type::begin_array == cursor.current().event_type());
93+
CHECK(semantic_tag::none == cursor.current().tag());
9494
cursor.next();
95-
CHECK(cursor.current().event_type() == staj_event_type::begin_array);
96-
CHECK(cursor.current().tag() == semantic_tag::none);
95+
CHECK(staj_event_type::begin_array == cursor.current().event_type());
96+
CHECK(semantic_tag::none == cursor.current().tag());
9797
cursor.next();
98-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
99-
CHECK(cursor.current().tag() == semantic_tag::none);
98+
CHECK(staj_event_type::string_value == cursor.current().event_type());
99+
CHECK(semantic_tag::none == cursor.current().tag());
100100
cursor.next();
101-
CHECK(cursor.current().event_type() == staj_event_type::byte_string_value);
102-
CHECK(cursor.current().tag() == semantic_tag::none);
101+
CHECK(staj_event_type::byte_string_value == cursor.current().event_type());
102+
CHECK(semantic_tag::none == cursor.current().tag());
103103
cursor.next();
104-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
105-
CHECK(cursor.current().tag() == semantic_tag::bigint);
104+
CHECK(staj_event_type::string_value == cursor.current().event_type());
105+
CHECK(semantic_tag::bigint == cursor.current().tag());
106106
cursor.next();
107-
CHECK(cursor.current().event_type() == staj_event_type::end_array);
108-
CHECK(cursor.current().tag() == semantic_tag::none);
107+
CHECK(staj_event_type::end_array == cursor.current().event_type());
108+
CHECK(semantic_tag::none == cursor.current().tag());
109109
cursor.next();
110-
CHECK(cursor.current().event_type() == staj_event_type::begin_array);
111-
CHECK(cursor.current().tag() == semantic_tag::none);
110+
CHECK(staj_event_type::begin_array == cursor.current().event_type());
111+
CHECK(semantic_tag::none == cursor.current().tag());
112112
cursor.next();
113-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
114-
CHECK(cursor.current().tag() == semantic_tag::none);
113+
CHECK(staj_event_type::string_value == cursor.current().event_type());
114+
CHECK(semantic_tag::none == cursor.current().tag());
115115
cursor.next();
116-
CHECK(cursor.current().event_type() == staj_event_type::byte_string_value);
117-
CHECK(cursor.current().tag() == semantic_tag::base64);
116+
CHECK(staj_event_type::byte_string_value == cursor.current().event_type());
117+
CHECK(semantic_tag::base64 == cursor.current().tag());
118118
cursor.next();
119-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
120-
CHECK(cursor.current().tag() == semantic_tag::bigdec);
119+
CHECK(staj_event_type::string_value == cursor.current().event_type());
120+
CHECK(semantic_tag::bigdec == cursor.current().tag());
121121
cursor.next();
122-
CHECK(cursor.current().event_type() == staj_event_type::end_array);
123-
CHECK(cursor.current().tag() == semantic_tag::none);
122+
CHECK(staj_event_type::end_array == cursor.current().event_type());
123+
CHECK(semantic_tag::none == cursor.current().tag());
124124
cursor.next();
125-
CHECK(cursor.current().event_type() == staj_event_type::end_array);
126-
CHECK(cursor.current().tag() == semantic_tag::none);
125+
CHECK(staj_event_type::end_array == cursor.current().event_type());
126+
CHECK(semantic_tag::none == cursor.current().tag());
127127
cursor.next();
128128
CHECK(cursor.done());
129129
}
@@ -311,27 +311,27 @@ TEMPLATE_TEST_CASE("cbor_cursor reset test", "",
311311
cursor_type cursor(std::move(source));
312312

313313
REQUIRE_FALSE(cursor.done());
314-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
315-
CHECK(cursor.current().tag() == semantic_tag::none);
316-
CHECK(cursor.current().template get<std::string>() == std::string("Tom"));
314+
CHECK(staj_event_type::string_value == cursor.current().event_type());
315+
CHECK(semantic_tag::none == cursor.current().tag());
316+
CHECK(std::string("Tom") == cursor.current().template get<std::string>());
317317
CHECK(cursor.current().template get<jsoncons::string_view>() ==
318318
jsoncons::string_view("Tom"));
319319
cursor.next();
320320
CHECK(cursor.done());
321321

322322
cursor.reset();
323323
REQUIRE_FALSE(cursor.done());
324-
CHECK(cursor.current().event_type() == staj_event_type::int64_value);
325-
CHECK(cursor.current().tag() == semantic_tag::none);
326-
CHECK(cursor.current().template get<int>() == -100);
324+
CHECK(staj_event_type::int64_value == cursor.current().event_type());
325+
CHECK(semantic_tag::none == cursor.current().tag());
326+
CHECK(-100 == cursor.current().template get<int>());
327327
cursor.next();
328328
CHECK(cursor.done());
329329

330330
cursor.reset(ec);
331331
REQUIRE_FALSE(ec);
332332
REQUIRE_FALSE(cursor.done());
333-
CHECK(cursor.current().event_type() == staj_event_type::null_value);
334-
CHECK(cursor.current().tag() == semantic_tag::none);
333+
CHECK(staj_event_type::null_value == cursor.current().event_type());
334+
CHECK(semantic_tag::none == cursor.current().tag());
335335
cursor.next(ec);
336336
REQUIRE_FALSE(ec);
337337
CHECK(cursor.done());
@@ -357,9 +357,9 @@ TEMPLATE_TEST_CASE("cbor_cursor reset test", "",
357357

358358
// Reset to valid input1
359359
cursor.reset(input1);
360-
CHECK(cursor.current().event_type() == staj_event_type::string_value);
361-
CHECK(cursor.current().tag() == semantic_tag::none);
362-
CHECK(cursor.current().template get<std::string>() == std::string("Tom"));
360+
CHECK(staj_event_type::string_value == cursor.current().event_type());
361+
CHECK(semantic_tag::none == cursor.current().tag());
362+
CHECK(std::string("Tom") == cursor.current().template get<std::string>());
363363
CHECK(cursor.current().template get<jsoncons::string_view>() ==
364364
jsoncons::string_view("Tom"));
365365
ec = cbor::cbor_errc::success;
@@ -378,9 +378,9 @@ TEMPLATE_TEST_CASE("cbor_cursor reset test", "",
378378
ec = cbor::cbor_errc::success;
379379
cursor.reset(input3, ec);
380380
REQUIRE_FALSE(ec);
381-
CHECK(cursor.current().event_type() == staj_event_type::int64_value);
382-
CHECK(cursor.current().tag() == semantic_tag::none);
383-
CHECK(cursor.current().template get<int>() == -100);
381+
CHECK(staj_event_type::int64_value == cursor.current().event_type());
382+
CHECK(semantic_tag::none == cursor.current().tag());
383+
CHECK(-100 == cursor.current().template get<int>());
384384
REQUIRE_FALSE(cursor.done());
385385
cursor.next(ec);
386386
CHECK_FALSE(ec);

test/cbor/src/cbor_encoder_tests.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -550,28 +550,28 @@ TEST_CASE("test cbor encode with raw tags")
550550
encoder.flush();
551551

552552
cbor::cbor_bytes_cursor cursor(data);
553-
CHECK(cursor.raw_tag() == 0xB1);
554-
CHECK(cursor.current().event_type() == jsoncons::staj_event_type::begin_array);
553+
CHECK(0xB1 == cursor.raw_tag());
554+
CHECK(jsoncons::staj_event_type::begin_array == cursor.current().event_type());
555555
cursor.next();
556-
CHECK(cursor.raw_tag() == 0xC1);
557-
CHECK(cursor.current().event_type() == jsoncons::staj_event_type::null_value);
556+
CHECK(0xC1 == cursor.raw_tag());
557+
CHECK(jsoncons::staj_event_type::null_value == cursor.current().event_type());
558558
cursor.next();
559-
CHECK(cursor.raw_tag() == 0xC2);
560-
CHECK(cursor.current().get<bool>() == false);
559+
CHECK(0xC2 == cursor.raw_tag());
560+
CHECK(false == cursor.current().get<bool>());
561561
cursor.next();
562-
CHECK(cursor.raw_tag() == 0xC3);
563-
CHECK(cursor.current().get<uint64_t>() == 1);
562+
CHECK(0xC3 == cursor.raw_tag());
563+
CHECK(1 == cursor.current().get<uint64_t>());
564564
cursor.next();
565-
CHECK(cursor.raw_tag() == 0xC4);
566-
CHECK(cursor.current().get<int64_t>() == -10);
565+
CHECK(0xC4 == cursor.raw_tag());
566+
CHECK(-10 == cursor.current().get<int64_t>());
567567
cursor.next();
568-
CHECK(cursor.raw_tag() == 0xC5);
569-
CHECK(cursor.current().get<double>() == Approx(10.5).epsilon(0.00001));
568+
CHECK(0xC5 == cursor.raw_tag());
569+
CHECK(Approx(10.5).epsilon(0.00001) == cursor.current().get<double>());
570570
cursor.next();
571-
CHECK(cursor.raw_tag() == 0xC6);
572-
CHECK(cursor.current().get<std::vector<uint8_t>>() == std::vector<uint8_t>{0x01,0x02,0x03});
571+
CHECK(0xC6 == cursor.raw_tag());
572+
CHECK(std::vector<uint8_t>{0x01,0x02,0x03} == cursor.current().get<std::vector<uint8_t>>());
573573
cursor.next();
574-
CHECK(cursor.raw_tag() == 0xD1);
575-
CHECK(cursor.current().event_type() == jsoncons::staj_event_type::begin_object);
574+
CHECK(0xD1 == cursor.raw_tag());
575+
CHECK(jsoncons::staj_event_type::begin_object == cursor.current().event_type());
576576
}
577577
}

test/cbor/src/cbor_typed_array_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ TEST_CASE("cbor typed array cursor tests")
9292
};
9393

9494
cbor::cbor_bytes_cursor cursor(input);
95-
CHECK(cursor.current().event_type() == staj_event_type::begin_array);
95+
CHECK(staj_event_type::begin_array == cursor.current().event_type());
9696
CHECK(cursor.is_typed_array());
9797

9898
my_cbor_visitor visitor;

0 commit comments

Comments
 (0)