File: conformance_iarna_invalid.cpp

package info (click to toggle)
tomlplusplus 3.3.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,184 kB
  • sloc: cpp: 35,145; ansic: 2,220; python: 983; makefile: 25; sh: 17
file content (451 lines) | stat: -rw-r--r-- 14,901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
// This file is a part of toml++ and is subject to the the terms of the MIT license.
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
// SPDX-License-Identifier: MIT
//-----
// this file was generated by generate_conformance_tests.py - do not modify it directly

#include "tests.h"

namespace
{
	static constexpr auto array_of_tables_1 = "# INVALID TOML DOC\r\n"
											  "fruit = []\r\n"
											  "\r\n"
											  "[[fruit]] # Not allowed"sv;
	static constexpr auto array_of_tables_2 = "# INVALID TOML DOC\r\n"
											  "[[fruit]]\r\n"
											  "  name = \"apple\"\r\n"
											  "\r\n"
											  "  [[fruit.variety]]\r\n"
											  "    name = \"red delicious\"\r\n"
											  "\r\n"
											  "  # This table conflicts with the previous table\r\n"
											  "  [fruit.variety]\r\n"
											  "    name = \"granny smith\""sv;

	static constexpr auto bare_key_1 = "bare!key = 123"sv;
	static constexpr auto bare_key_2 = "barekey\r\n"
									   "   = 123"sv;
	static constexpr auto bare_key_3 = R"(barekey =)"sv;

	static constexpr auto comment_control_1 = "a = \"null\" # \x00"sv;
	static constexpr auto comment_control_2 = "a = \"ctrl-P\" # \x10"sv;
	static constexpr auto comment_control_3 = "a = \"ctrl-_\" # \x1F"sv;
	static constexpr auto comment_control_4 = "a = \"0x7f\" # \x7F"sv;

	static constexpr auto inline_table_imutable_1 = "[product]\r\n"
													"type = { name = \"Nail\" }\r\n"
													"type.edible = false  # INVALID"sv;
	static constexpr auto inline_table_imutable_2 = "[product]\r\n"
													"type.name = \"Nail\"\r\n"
													"type = { edible = false }  # INVALID"sv;

#if !TOML_LANG_UNRELEASED

	static constexpr auto inline_table_trailing_comma = "abc = { abc = 123, }"sv;

#endif // !TOML_LANG_UNRELEASED

	static constexpr auto int_0_padded	 = "int = 0123"sv;
	static constexpr auto int_signed_bin = "bin = +0b10"sv;
	static constexpr auto int_signed_hex = "hex = +0xab"sv;
	static constexpr auto int_signed_oct = "oct = +0o23"sv;

	static constexpr auto key_value_pair_1 = "key = # INVALID"sv;
	static constexpr auto key_value_pair_2 = "first = \"Tom\" last = \"Preston-Werner\" # INVALID"sv;

	static constexpr auto multiple_dot_key = "# THE FOLLOWING IS INVALID\r\n"
											 "\r\n"
											 "# This defines the value of fruit.apple to be an integer.\r\n"
											 "fruit.apple = 1\r\n"
											 "\r\n"
											 "# But then this treats fruit.apple like it's a table.\r\n"
											 "# You can't turn an integer into a table.\r\n"
											 "fruit.apple.smooth = true"sv;
	static constexpr auto multiple_key	   = "# DO NOT DO THIS\r\n"
											 "name = \"Tom\"\r\n"
											 "name = \"Pradyun\""sv;

	static constexpr auto no_key_name = "= \"no key name\"  # INVALID"sv;

	static constexpr auto string_basic_control_1							   = "a = \"null\x00\""sv;
	static constexpr auto string_basic_control_2							   = "a = \"ctrl-P\x10\""sv;
	static constexpr auto string_basic_control_3							   = "a = \"ctrl-_\x1F\""sv;
	static constexpr auto string_basic_control_4							   = "a = \"0x7f\x7F\""sv;
	static constexpr auto string_basic_multiline_control_1					   = "a = \"\"\"null\x00\"\"\""sv;
	static constexpr auto string_basic_multiline_control_2					   = "a = \"\"\"null\x10\"\"\""sv;
	static constexpr auto string_basic_multiline_control_3					   = "a = \"\"\"null\x1F\"\"\""sv;
	static constexpr auto string_basic_multiline_control_4					   = "a = \"\"\"null\x7F\"\"\""sv;
	static constexpr auto string_basic_multiline_invalid_backslash			   = "a = \"\"\"\r\n"
																				 "  foo \\ \\n\r\n"
																				 "  bar\"\"\""sv;
	static constexpr auto string_basic_multiline_out_of_range_unicode_escape_1 = "a = \"\"\"\\UFFFFFFFF\"\"\""sv;
	static constexpr auto string_basic_multiline_out_of_range_unicode_escape_2 = "a = \"\"\"\\U00D80000\"\"\""sv;
	static constexpr auto string_basic_multiline_quotes =
		"str5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\""sv;
	static constexpr auto string_basic_multiline_unknown_escape		 = "a = \"\"\"\\@\"\"\""sv;
	static constexpr auto string_basic_out_of_range_unicode_escape_1 = "a = \"\\UFFFFFFFF\""sv;
	static constexpr auto string_basic_out_of_range_unicode_escape_2 = "a = \"\\U00D80000\""sv;
	static constexpr auto string_basic_unknown_escape				 = "a = \"\\@\""sv;
	static constexpr auto string_literal_control_1					 = "a = 'null\x00'"sv;
	static constexpr auto string_literal_control_2					 = "a = 'null\x10'"sv;
	static constexpr auto string_literal_control_3					 = "a = 'null\x1F'"sv;
	static constexpr auto string_literal_control_4					 = "a = 'null\x7F'"sv;
	static constexpr auto string_literal_multiline_control_1		 = "a = '''null\x00'''"sv;
	static constexpr auto string_literal_multiline_control_2		 = "a = '''null\x10'''"sv;
	static constexpr auto string_literal_multiline_control_3		 = "a = '''null\x1F'''"sv;
	static constexpr auto string_literal_multiline_control_4		 = "a = '''null\x7F'''"sv;
	static constexpr auto string_literal_multiline_quotes =
		"apos15 = '''Here are fifteen apostrophes: ''''''''''''''''''  # INVALID"sv;

	static constexpr auto table_1 = "# DO NOT DO THIS\r\n"
									"\r\n"
									"[fruit]\r\n"
									"apple = \"red\"\r\n"
									"\r\n"
									"[fruit]\r\n"
									"orange = \"orange\""sv;
	static constexpr auto table_2 = "# DO NOT DO THIS EITHER\r\n"
									"\r\n"
									"[fruit]\r\n"
									"apple = \"red\"\r\n"
									"\r\n"
									"[fruit.apple]\r\n"
									"texture = \"smooth\""sv;
	static constexpr auto table_3 = "[fruit]\r\n"
									"apple.color = \"red\"\r\n"
									"apple.taste.sweet = true\r\n"
									"\r\n"
									"[fruit.apple]  # INVALID"sv;
	static constexpr auto table_4 = "[fruit]\r\n"
									"apple.color = \"red\"\r\n"
									"apple.taste.sweet = true\r\n"
									"\r\n"
									"[fruit.apple.taste]  # INVALID"sv;
	static constexpr auto table_invalid_1 =
		"[fruit.physical]  # subtable, but to which parent element should it belong?\r\n"
		"  color = \"red\"\r\n"
		"  shape = \"round\"\r\n"
		"\r\n"
		"[[fruit]]  # parser must throw an error upon discovering that \"fruit\" is\r\n"
		"           # an array rather than a table\r\n"
		"  name = \"apple\""sv;
	static constexpr auto table_invalid_2 = "# INVALID TOML DOC\r\n"
											"fruit = []\r\n"
											"\r\n"
											"[[fruit]] # Not allowed"sv;
	static constexpr auto table_invalid_3 = "# INVALID TOML DOC\r\n"
											"[[fruit]]\r\n"
											"  name = \"apple\"\r\n"
											"\r\n"
											"  [[fruit.variety]]\r\n"
											"    name = \"red delicious\"\r\n"
											"\r\n"
											"  # INVALID: This table conflicts with the previous array of tables\r\n"
											"  [fruit.variety]\r\n"
											"    name = \"granny smith\"\r\n"
											"\r\n"
											"  [fruit.physical]\r\n"
											"    color = \"red\"\r\n"
											"    shape = \"round\""sv;
	static constexpr auto table_invalid_4 = "# INVALID TOML DOC\r\n"
											"[[fruit]]\r\n"
											"  name = \"apple\"\r\n"
											"\r\n"
											"  [[fruit.variety]]\r\n"
											"    name = \"red delicious\"\r\n"
											"\r\n"
											"  [fruit.physical]\r\n"
											"    color = \"red\"\r\n"
											"    shape = \"round\"\r\n"
											"\r\n"
											"  # INVALID: This array of tables conflicts with the previous table\r\n"
											"  [[fruit.physical]]\r\n"
											"    color = \"green\""sv;
}

TEST_CASE("conformance - iarna/invalid")
{
	SECTION("array-of-tables-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1); // array-of-tables-1
	}

	SECTION("array-of-tables-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); // array-of-tables-2
	}

	SECTION("bare-key-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, bare_key_1); // bare-key-1
	}

	SECTION("bare-key-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, bare_key_2); // bare-key-2
	}

	SECTION("bare-key-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, bare_key_3); // bare-key-3
	}

	SECTION("comment-control-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, comment_control_1); // comment-control-1
	}

	SECTION("comment-control-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, comment_control_2); // comment-control-2
	}

	SECTION("comment-control-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, comment_control_3); // comment-control-3
	}

	SECTION("comment-control-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, comment_control_4); // comment-control-4
	}

	SECTION("inline-table-imutable-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1); // inline-table-imutable-1
	}

	SECTION("inline-table-imutable-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2); // inline-table-imutable-2
	}

#if !TOML_LANG_UNRELEASED

	SECTION("inline-table-trailing-comma")
	{
		parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma
	}

#endif // !TOML_LANG_UNRELEASED

	SECTION("int-0-padded")
	{
		parsing_should_fail(FILE_LINE_ARGS, int_0_padded); // int-0-padded
	}

	SECTION("int-signed-bin")
	{
		parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); // int-signed-bin
	}

	SECTION("int-signed-hex")
	{
		parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); // int-signed-hex
	}

	SECTION("int-signed-oct")
	{
		parsing_should_fail(FILE_LINE_ARGS, int_signed_oct); // int-signed-oct
	}

	SECTION("key-value-pair-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1); // key-value-pair-1
	}

	SECTION("key-value-pair-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2); // key-value-pair-2
	}

	SECTION("multiple-dot-key")
	{
		parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key); // multiple-dot-key
	}

	SECTION("multiple-key")
	{
		parsing_should_fail(FILE_LINE_ARGS, multiple_key); // multiple-key
	}

	SECTION("no-key-name")
	{
		parsing_should_fail(FILE_LINE_ARGS, no_key_name); // no-key-name
	}

	SECTION("string-basic-control-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_control_1); // string-basic-control-1
	}

	SECTION("string-basic-control-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_control_2); // string-basic-control-2
	}

	SECTION("string-basic-control-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_control_3); // string-basic-control-3
	}

	SECTION("string-basic-control-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_control_4); // string-basic-control-4
	}

	SECTION("string-basic-multiline-control-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_1); // string-basic-multiline-control-1
	}

	SECTION("string-basic-multiline-control-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_2); // string-basic-multiline-control-2
	}

	SECTION("string-basic-multiline-control-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_3); // string-basic-multiline-control-3
	}

	SECTION("string-basic-multiline-control-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_4); // string-basic-multiline-control-4
	}

	SECTION("string-basic-multiline-invalid-backslash")
	{
		parsing_should_fail(FILE_LINE_ARGS,
							string_basic_multiline_invalid_backslash); // string-basic-multiline-invalid-backslash
	}

	SECTION("string-basic-multiline-out-of-range-unicode-escape-1")
	{
		parsing_should_fail(
			FILE_LINE_ARGS,
			string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1
	}

	SECTION("string-basic-multiline-out-of-range-unicode-escape-2")
	{
		parsing_should_fail(
			FILE_LINE_ARGS,
			string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2
	}

	SECTION("string-basic-multiline-quotes")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes
	}

	SECTION("string-basic-multiline-unknown-escape")
	{
		parsing_should_fail(FILE_LINE_ARGS,
							string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape
	}

	SECTION("string-basic-out-of-range-unicode-escape-1")
	{
		parsing_should_fail(FILE_LINE_ARGS,
							string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1
	}

	SECTION("string-basic-out-of-range-unicode-escape-2")
	{
		parsing_should_fail(FILE_LINE_ARGS,
							string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2
	}

	SECTION("string-basic-unknown-escape")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape
	}

	SECTION("string-literal-control-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_control_1); // string-literal-control-1
	}

	SECTION("string-literal-control-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_control_2); // string-literal-control-2
	}

	SECTION("string-literal-control-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_control_3); // string-literal-control-3
	}

	SECTION("string-literal-control-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_control_4); // string-literal-control-4
	}

	SECTION("string-literal-multiline-control-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_1); // string-literal-multiline-control-1
	}

	SECTION("string-literal-multiline-control-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_2); // string-literal-multiline-control-2
	}

	SECTION("string-literal-multiline-control-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_3); // string-literal-multiline-control-3
	}

	SECTION("string-literal-multiline-control-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_4); // string-literal-multiline-control-4
	}

	SECTION("string-literal-multiline-quotes")
	{
		parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes); // string-literal-multiline-quotes
	}

	SECTION("table-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_1); // table-1
	}

	SECTION("table-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_2); // table-2
	}

	SECTION("table-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_3); // table-3
	}

	SECTION("table-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_4); // table-4
	}

	SECTION("table-invalid-1")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); // table-invalid-1
	}

	SECTION("table-invalid-2")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); // table-invalid-2
	}

	SECTION("table-invalid-3")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); // table-invalid-3
	}

	SECTION("table-invalid-4")
	{
		parsing_should_fail(FILE_LINE_ARGS, table_invalid_4); // table-invalid-4
	}
}