1
2 package toml_test
3
4 import (
5 "testing"
6 )
7
8 func TestTOMLTest_Invalid_Tests_Invalid_Array_DoubleComma1(t *testing.T) {
9 input := "double-comma-1 = [1,,2]\n"
10 testgenInvalid(t, input)
11 }
12
13 func TestTOMLTest_Invalid_Tests_Invalid_Array_DoubleComma2(t *testing.T) {
14 input := "double-comma-2 = [1,2,,]\n"
15 testgenInvalid(t, input)
16 }
17
18 func TestTOMLTest_Invalid_Tests_Invalid_Array_ExtendDefinedAot(t *testing.T) {
19 input := "[[tab.arr]]\n[tab]\narr.val1=1\n"
20 testgenInvalid(t, input)
21 }
22
23 func TestTOMLTest_Invalid_Tests_Invalid_Array_ExtendingTable(t *testing.T) {
24 input := "a = [{ b = 1 }]\n\n# Cannot extend tables within static arrays\n# https://github.com/toml-lang/toml/issues/908\n[a.c]\nfoo = 1\n"
25 testgenInvalid(t, input)
26 }
27
28 func TestTOMLTest_Invalid_Tests_Invalid_Array_MissingSeparator1(t *testing.T) {
29 input := "arrr = [true false]\n"
30 testgenInvalid(t, input)
31 }
32
33 func TestTOMLTest_Invalid_Tests_Invalid_Array_MissingSeparator2(t *testing.T) {
34 input := "wrong = [ 1 2 3 ]\n"
35 testgenInvalid(t, input)
36 }
37
38 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose1(t *testing.T) {
39 input := "no-close-1 = [ 1, 2, 3\n"
40 testgenInvalid(t, input)
41 }
42
43 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose2(t *testing.T) {
44 input := "no-close-2 = [1,\n"
45 testgenInvalid(t, input)
46 }
47
48 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose3(t *testing.T) {
49 input := "no-close-3 = [42 #]\n"
50 testgenInvalid(t, input)
51 }
52
53 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose4(t *testing.T) {
54 input := "no-close-4 = [{ key = 42\n"
55 testgenInvalid(t, input)
56 }
57
58 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose5(t *testing.T) {
59 input := "no-close-5 = [{ key = 42}\n"
60 testgenInvalid(t, input)
61 }
62
63 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose6(t *testing.T) {
64 input := "no-close-6 = [{ key = 42 #}]\n"
65 testgenInvalid(t, input)
66 }
67
68 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose7(t *testing.T) {
69 input := "no-close-7 = [{ key = 42} #]\n"
70 testgenInvalid(t, input)
71 }
72
73 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose8(t *testing.T) {
74 input := "no-close-8 = [\n"
75 testgenInvalid(t, input)
76 }
77
78 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoCloseTable1(t *testing.T) {
79 input := "x = [{ key = 42\n"
80 testgenInvalid(t, input)
81 }
82
83 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoCloseTable2(t *testing.T) {
84 input := "x = [{ key = 42 #\n"
85 testgenInvalid(t, input)
86 }
87
88 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma1(t *testing.T) {
89 input := "no-comma-1 = [true false]\n"
90 testgenInvalid(t, input)
91 }
92
93 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma2(t *testing.T) {
94 input := "no-comma-2 = [ 1 2 3 ]\n"
95 testgenInvalid(t, input)
96 }
97
98 func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma3(t *testing.T) {
99 input := "no-comma-3 = [ 1 #,]\n"
100 testgenInvalid(t, input)
101 }
102
103 func TestTOMLTest_Invalid_Tests_Invalid_Array_OnlyComma1(t *testing.T) {
104 input := "only-comma-1 = [,]\n"
105 testgenInvalid(t, input)
106 }
107
108 func TestTOMLTest_Invalid_Tests_Invalid_Array_OnlyComma2(t *testing.T) {
109 input := "only-comma-2 = [,,]\n"
110 testgenInvalid(t, input)
111 }
112
113 func TestTOMLTest_Invalid_Tests_Invalid_Array_Tables1(t *testing.T) {
114 input := "# INVALID TOML DOC\nfruit = []\n\n[[fruit]] # Not allowed\n"
115 testgenInvalid(t, input)
116 }
117
118 func TestTOMLTest_Invalid_Tests_Invalid_Array_Tables2(t *testing.T) {
119 input := "# INVALID TOML DOC\n[[fruit]]\n name = \"apple\"\n\n [[fruit.variety]]\n name = \"red delicious\"\n\n # This table conflicts with the previous table\n [fruit.variety]\n name = \"granny smith\"\n"
120 testgenInvalid(t, input)
121 }
122
123 func TestTOMLTest_Invalid_Tests_Invalid_Array_TextAfterArrayEntries(t *testing.T) {
124 input := "array = [\n \"Is there life after an array separator?\", No\n \"Entry\"\n]\n"
125 testgenInvalid(t, input)
126 }
127
128 func TestTOMLTest_Invalid_Tests_Invalid_Array_TextBeforeArraySeparator(t *testing.T) {
129 input := "array = [\n \"Is there life before an array separator?\" No,\n \"Entry\"\n]\n"
130 testgenInvalid(t, input)
131 }
132
133 func TestTOMLTest_Invalid_Tests_Invalid_Array_TextInArray(t *testing.T) {
134 input := "array = [\n \"Entry 1\",\n I don't belong,\n \"Entry 2\",\n]\n"
135 testgenInvalid(t, input)
136 }
137
138 func TestTOMLTest_Invalid_Tests_Invalid_Bool_AlmostFalseWithExtra(t *testing.T) {
139 input := "almost-false-with-extra = falsify\n"
140 testgenInvalid(t, input)
141 }
142
143 func TestTOMLTest_Invalid_Tests_Invalid_Bool_AlmostFalse(t *testing.T) {
144 input := "almost-false = fals\n"
145 testgenInvalid(t, input)
146 }
147
148 func TestTOMLTest_Invalid_Tests_Invalid_Bool_AlmostTrueWithExtra(t *testing.T) {
149 input := "almost-true-with-extra = truthy\n"
150 testgenInvalid(t, input)
151 }
152
153 func TestTOMLTest_Invalid_Tests_Invalid_Bool_AlmostTrue(t *testing.T) {
154 input := "almost-true = tru\n"
155 testgenInvalid(t, input)
156 }
157
158 func TestTOMLTest_Invalid_Tests_Invalid_Bool_CapitalizedFalse(t *testing.T) {
159 input := "capitalized-false = False\n"
160 testgenInvalid(t, input)
161 }
162
163 func TestTOMLTest_Invalid_Tests_Invalid_Bool_CapitalizedTrue(t *testing.T) {
164 input := "capitalized-true = True\n"
165 testgenInvalid(t, input)
166 }
167
168 func TestTOMLTest_Invalid_Tests_Invalid_Bool_JustF(t *testing.T) {
169 input := "just-f = f\n"
170 testgenInvalid(t, input)
171 }
172
173 func TestTOMLTest_Invalid_Tests_Invalid_Bool_JustT(t *testing.T) {
174 input := "just-t = t\n"
175 testgenInvalid(t, input)
176 }
177
178 func TestTOMLTest_Invalid_Tests_Invalid_Bool_MixedCaseFalse(t *testing.T) {
179 input := "mixed-case-false = falsE\n"
180 testgenInvalid(t, input)
181 }
182
183 func TestTOMLTest_Invalid_Tests_Invalid_Bool_MixedCaseTrue(t *testing.T) {
184 input := "mixed-case-true = trUe\n"
185 testgenInvalid(t, input)
186 }
187
188 func TestTOMLTest_Invalid_Tests_Invalid_Bool_MixedCase(t *testing.T) {
189 input := "mixed-case = valid = False\n"
190 testgenInvalid(t, input)
191 }
192
193 func TestTOMLTest_Invalid_Tests_Invalid_Bool_StartingSameFalse(t *testing.T) {
194 input := "starting-same-false = falsey\n"
195 testgenInvalid(t, input)
196 }
197
198 func TestTOMLTest_Invalid_Tests_Invalid_Bool_StartingSameTrue(t *testing.T) {
199 input := "starting-same-true = truer\n"
200 testgenInvalid(t, input)
201 }
202
203 func TestTOMLTest_Invalid_Tests_Invalid_Bool_WrongCaseFalse(t *testing.T) {
204 input := "wrong-case-false = FALSE\n"
205 testgenInvalid(t, input)
206 }
207
208 func TestTOMLTest_Invalid_Tests_Invalid_Bool_WrongCaseTrue(t *testing.T) {
209 input := "wrong-case-true = TRUE\n"
210 testgenInvalid(t, input)
211 }
212
213 func TestTOMLTest_Invalid_Tests_Invalid_Control_BareCr(t *testing.T) {
214 input := "# The following line contains a single carriage return control character\r\n\r"
215 testgenInvalid(t, input)
216 }
217
218 func TestTOMLTest_Invalid_Tests_Invalid_Control_BareFormfeed(t *testing.T) {
219 input := "bare-formfeed = \f\n"
220 testgenInvalid(t, input)
221 }
222
223 func TestTOMLTest_Invalid_Tests_Invalid_Control_BareNull(t *testing.T) {
224 input := "bare-null = \"some value\" \x00\n"
225 testgenInvalid(t, input)
226 }
227
228 func TestTOMLTest_Invalid_Tests_Invalid_Control_BareVerticalTab(t *testing.T) {
229 input := "bare-vertical-tab = \v\n"
230 testgenInvalid(t, input)
231 }
232
233 func TestTOMLTest_Invalid_Tests_Invalid_Control_CommentCr(t *testing.T) {
234 input := "comment-cr = \"Carriage return in comment\" # \ra=1\n"
235 testgenInvalid(t, input)
236 }
237
238 func TestTOMLTest_Invalid_Tests_Invalid_Control_CommentDel(t *testing.T) {
239 input := "comment-del = \"0x7f\" # \x7f\n"
240 testgenInvalid(t, input)
241 }
242
243 func TestTOMLTest_Invalid_Tests_Invalid_Control_CommentFf(t *testing.T) {
244 input := "comment-ff = \"0x7f\" # \f\n"
245 testgenInvalid(t, input)
246 }
247
248 func TestTOMLTest_Invalid_Tests_Invalid_Control_CommentLf(t *testing.T) {
249 input := "comment-lf = \"ctrl-P\" # \x10\n"
250 testgenInvalid(t, input)
251 }
252
253 func TestTOMLTest_Invalid_Tests_Invalid_Control_CommentNull(t *testing.T) {
254 input := "comment-null = \"null\" # \x00\n"
255 testgenInvalid(t, input)
256 }
257
258 func TestTOMLTest_Invalid_Tests_Invalid_Control_CommentUs(t *testing.T) {
259 input := "comment-us = \"ctrl-_\" # \x1f\n"
260 testgenInvalid(t, input)
261 }
262
263 func TestTOMLTest_Invalid_Tests_Invalid_Control_MultiCr(t *testing.T) {
264 input := "multi-cr = \"\"\"null\r\"\"\"\n"
265 testgenInvalid(t, input)
266 }
267
268 func TestTOMLTest_Invalid_Tests_Invalid_Control_MultiDel(t *testing.T) {
269 input := "multi-del = \"\"\"null\x7f\"\"\"\n"
270 testgenInvalid(t, input)
271 }
272
273 func TestTOMLTest_Invalid_Tests_Invalid_Control_MultiLf(t *testing.T) {
274 input := "multi-lf = \"\"\"null\x10\"\"\"\n"
275 testgenInvalid(t, input)
276 }
277
278 func TestTOMLTest_Invalid_Tests_Invalid_Control_MultiNull(t *testing.T) {
279 input := "multi-null = \"\"\"null\x00\"\"\"\n"
280 testgenInvalid(t, input)
281 }
282
283 func TestTOMLTest_Invalid_Tests_Invalid_Control_MultiUs(t *testing.T) {
284 input := "multi-us = \"\"\"null\x1f\"\"\"\n"
285 testgenInvalid(t, input)
286 }
287
288 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawmultiCd(t *testing.T) {
289 input := "rawmulti-cd = '''null\r'''\n"
290 testgenInvalid(t, input)
291 }
292
293 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawmultiDel(t *testing.T) {
294 input := "rawmulti-del = '''null\x7f'''\n"
295 testgenInvalid(t, input)
296 }
297
298 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawmultiLf(t *testing.T) {
299 input := "rawmulti-lf = '''null\x10'''\n"
300 testgenInvalid(t, input)
301 }
302
303 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawmultiNull(t *testing.T) {
304 input := "rawmulti-null = '''null\x00'''\n"
305 testgenInvalid(t, input)
306 }
307
308 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawmultiUs(t *testing.T) {
309 input := "rawmulti-us = '''null\x1f'''\n"
310 testgenInvalid(t, input)
311 }
312
313 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawstringCr(t *testing.T) {
314 input := "rawstring-cr = 'null\r'\n"
315 testgenInvalid(t, input)
316 }
317
318 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawstringDel(t *testing.T) {
319 input := "rawstring-del = 'null\x7f'\n"
320 testgenInvalid(t, input)
321 }
322
323 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawstringLf(t *testing.T) {
324 input := "rawstring-lf = 'null\x10'\n"
325 testgenInvalid(t, input)
326 }
327
328 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawstringNull(t *testing.T) {
329 input := "rawstring-null = 'null\x00'\n"
330 testgenInvalid(t, input)
331 }
332
333 func TestTOMLTest_Invalid_Tests_Invalid_Control_RawstringUs(t *testing.T) {
334 input := "rawstring-us = 'null\x1f'\n"
335 testgenInvalid(t, input)
336 }
337
338 func TestTOMLTest_Invalid_Tests_Invalid_Control_StringBs(t *testing.T) {
339 input := "string-bs = \"backspace\b\"\n"
340 testgenInvalid(t, input)
341 }
342
343 func TestTOMLTest_Invalid_Tests_Invalid_Control_StringCr(t *testing.T) {
344 input := "string-cr = \"null\r\"\n"
345 testgenInvalid(t, input)
346 }
347
348 func TestTOMLTest_Invalid_Tests_Invalid_Control_StringDel(t *testing.T) {
349 input := "string-del = \"null\x7f\"\n"
350 testgenInvalid(t, input)
351 }
352
353 func TestTOMLTest_Invalid_Tests_Invalid_Control_StringLf(t *testing.T) {
354 input := "string-lf = \"null\x10\"\n"
355 testgenInvalid(t, input)
356 }
357
358 func TestTOMLTest_Invalid_Tests_Invalid_Control_StringNull(t *testing.T) {
359 input := "string-null = \"null\x00\"\n"
360 testgenInvalid(t, input)
361 }
362
363 func TestTOMLTest_Invalid_Tests_Invalid_Control_StringUs(t *testing.T) {
364 input := "string-us = \"null\x1f\"\n"
365 testgenInvalid(t, input)
366 }
367
368 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_Feb29(t *testing.T) {
369 input := "\"not a leap year\" = 2100-02-29T15:15:15Z\n"
370 testgenInvalid(t, input)
371 }
372
373 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_Feb30(t *testing.T) {
374 input := "\"only 28 or 29 days in february\" = 1988-02-30T15:15:15Z\n"
375 testgenInvalid(t, input)
376 }
377
378 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_HourOver(t *testing.T) {
379 input := "# time-hour = 2DIGIT ; 00-23\nd = 2006-01-01T24:00:00-00:00\n"
380 testgenInvalid(t, input)
381 }
382
383 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_MdayOver(t *testing.T) {
384 input := "# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on\n# ; month/year\nd = 2006-01-32T00:00:00-00:00\n"
385 testgenInvalid(t, input)
386 }
387
388 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_MdayUnder(t *testing.T) {
389 input := "# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on\n# ; month/year\nd = 2006-01-00T00:00:00-00:00\n"
390 testgenInvalid(t, input)
391 }
392
393 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_MinuteOver(t *testing.T) {
394 input := "# time-minute = 2DIGIT ; 00-59\nd = 2006-01-01T00:60:00-00:00\n"
395 testgenInvalid(t, input)
396 }
397
398 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_MonthOver(t *testing.T) {
399 input := "# date-month = 2DIGIT ; 01-12\nd = 2006-13-01T00:00:00-00:00\n"
400 testgenInvalid(t, input)
401 }
402
403 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_MonthUnder(t *testing.T) {
404 input := "# date-month = 2DIGIT ; 01-12\nd = 2007-00-01T00:00:00-00:00\n"
405 testgenInvalid(t, input)
406 }
407
408 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoLeadsMonth(t *testing.T) {
409 input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05T17:45:00Z\n"
410 testgenInvalid(t, input)
411 }
412
413 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoLeadsWithMilli(t *testing.T) {
414 input := "# Day \"5\" instead of \"05\"; the leading zero is required.\nwith-milli = 1987-07-5T17:45:00.12Z\n"
415 testgenInvalid(t, input)
416 }
417
418 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoLeads(t *testing.T) {
419 input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05T17:45:00Z\n"
420 testgenInvalid(t, input)
421 }
422
423 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoSecs(t *testing.T) {
424 input := "# No seconds in time.\nno-secs = 1987-07-05T17:45Z\n"
425 testgenInvalid(t, input)
426 }
427
428 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoT(t *testing.T) {
429 input := "# No \"t\" or \"T\" between the date and time.\nno-t = 1987-07-0517:45:00Z\n"
430 testgenInvalid(t, input)
431 }
432
433 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_SecondOver(t *testing.T) {
434 input := "# time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second\n# ; rules\nd = 2006-01-01T00:00:61-00:00\n"
435 testgenInvalid(t, input)
436 }
437
438 func TestTOMLTest_Invalid_Tests_Invalid_Datetime_TimeNoLeads(t *testing.T) {
439 input := "# Leading 0 is always required.\nd = 2023-10-01T1:32:00Z\n"
440 testgenInvalid(t, input)
441 }
442
443 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadCodepoint(t *testing.T) {
444 input := "# Invalid codepoint U+D800 : \xed\xa0\x80\n"
445 testgenInvalid(t, input)
446 }
447
448 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8AtEnd(t *testing.T) {
449 input := "# There is a 0xda at after the quotes, and no EOL at the end of the file.\n#\n# This is a bit of an edge case: This indicates there should be two bytes\n# (0b1101_1010) but there is no byte to follow because it's the end of the file.\nx = \"\"\"\"\"\"\xda"
450 testgenInvalid(t, input)
451 }
452
453 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InComment(t *testing.T) {
454 input := "# \xc3\n"
455 testgenInvalid(t, input)
456 }
457
458 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InMultilineLiteral(t *testing.T) {
459 input := "# The following line contains an invalid UTF-8 sequence.\nbad = '''\xc3'''\n"
460 testgenInvalid(t, input)
461 }
462
463 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InMultiline(t *testing.T) {
464 input := "# The following line contains an invalid UTF-8 sequence.\nbad = \"\"\"\xc3\"\"\"\n"
465 testgenInvalid(t, input)
466 }
467
468 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InStringLiteral(t *testing.T) {
469 input := "# The following line contains an invalid UTF-8 sequence.\nbad = '\xc3'\n"
470 testgenInvalid(t, input)
471 }
472
473 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InString(t *testing.T) {
474 input := "# The following line contains an invalid UTF-8 sequence.\nbad = \"\xc3\"\n"
475 testgenInvalid(t, input)
476 }
477
478 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BomNotAtStart1(t *testing.T) {
479 input := "bom-not-at-start \xff\xfd\n"
480 testgenInvalid(t, input)
481 }
482
483 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BomNotAtStart2(t *testing.T) {
484 input := "bom-not-at-start= \xff\xfd\n"
485 testgenInvalid(t, input)
486 }
487
488 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_Utf16Bom(t *testing.T) {
489 input := "\xfe\xff\x00#\x00 \x00U\x00T\x00F\x00-\x001\x006\x00 \x00w\x00i\x00t\x00h\x00 \x00B\x00O\x00M\x00\n"
490 testgenInvalid(t, input)
491 }
492
493 func TestTOMLTest_Invalid_Tests_Invalid_Encoding_Utf16(t *testing.T) {
494 input := "\x00#\x00 \x00U\x00T\x00F\x00-\x001\x006\x00 \x00w\x00i\x00t\x00h\x00o\x00u\x00t\x00 \x00B\x00O\x00M\x00\n"
495 testgenInvalid(t, input)
496 }
497
498 func TestTOMLTest_Invalid_Tests_Invalid_Float_DoublePoint1(t *testing.T) {
499 input := "double-point-1 = 0..1\n"
500 testgenInvalid(t, input)
501 }
502
503 func TestTOMLTest_Invalid_Tests_Invalid_Float_DoublePoint2(t *testing.T) {
504 input := "double-point-2 = 0.1.2\n"
505 testgenInvalid(t, input)
506 }
507
508 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleE1(t *testing.T) {
509 input := "exp-double-e-1 = 1ee2\n"
510 testgenInvalid(t, input)
511 }
512
513 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleE2(t *testing.T) {
514 input := "exp-double-e-2 = 1e2e3\n"
515 testgenInvalid(t, input)
516 }
517
518 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleUs(t *testing.T) {
519 input := "exp-double-us = 1e__23\n"
520 testgenInvalid(t, input)
521 }
522
523 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpLeadingUs(t *testing.T) {
524 input := "exp-leading-us = 1e_23\n"
525 testgenInvalid(t, input)
526 }
527
528 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpPoint1(t *testing.T) {
529 input := "exp-point-1 = 1e2.3\n"
530 testgenInvalid(t, input)
531 }
532
533 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpPoint2(t *testing.T) {
534 input := "exp-point-2 = 1.e2\n"
535 testgenInvalid(t, input)
536 }
537
538 func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpTrailingUs(t *testing.T) {
539 input := "exp-trailing-us = 1e23_\n"
540 testgenInvalid(t, input)
541 }
542
543 func TestTOMLTest_Invalid_Tests_Invalid_Float_InfCapital(t *testing.T) {
544 input := "v = Inf\n"
545 testgenInvalid(t, input)
546 }
547
548 func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete1(t *testing.T) {
549 input := "inf-incomplete-1 = in\n"
550 testgenInvalid(t, input)
551 }
552
553 func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete2(t *testing.T) {
554 input := "inf-incomplete-2 = +in\n"
555 testgenInvalid(t, input)
556 }
557
558 func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete3(t *testing.T) {
559 input := "inf-incomplete-3 = -in\n"
560 testgenInvalid(t, input)
561 }
562
563 func TestTOMLTest_Invalid_Tests_Invalid_Float_Inf_underscore(t *testing.T) {
564 input := "inf_underscore = in_f\n"
565 testgenInvalid(t, input)
566 }
567
568 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingPointNeg(t *testing.T) {
569 input := "leading-point-neg = -.12345\n"
570 testgenInvalid(t, input)
571 }
572
573 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingPointPlus(t *testing.T) {
574 input := "leading-point-plus = +.12345\n"
575 testgenInvalid(t, input)
576 }
577
578 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingPoint(t *testing.T) {
579 input := "leading-point = .12345\n"
580 testgenInvalid(t, input)
581 }
582
583 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingUs(t *testing.T) {
584 input := "leading-us = _1.2\n"
585 testgenInvalid(t, input)
586 }
587
588 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingZeroNeg(t *testing.T) {
589 input := "leading-zero-neg = -03.14\n"
590 testgenInvalid(t, input)
591 }
592
593 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingZeroPlus(t *testing.T) {
594 input := "leading-zero-plus = +03.14\n"
595 testgenInvalid(t, input)
596 }
597
598 func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingZero(t *testing.T) {
599 input := "leading-zero = 03.14\n"
600 testgenInvalid(t, input)
601 }
602
603 func TestTOMLTest_Invalid_Tests_Invalid_Float_NanCapital(t *testing.T) {
604 input := "v = NaN\n"
605 testgenInvalid(t, input)
606 }
607
608 func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete1(t *testing.T) {
609 input := "nan-incomplete-1 = na\n"
610 testgenInvalid(t, input)
611 }
612
613 func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete2(t *testing.T) {
614 input := "nan-incomplete-2 = +na\n"
615 testgenInvalid(t, input)
616 }
617
618 func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete3(t *testing.T) {
619 input := "nan-incomplete-3 = -na\n"
620 testgenInvalid(t, input)
621 }
622
623 func TestTOMLTest_Invalid_Tests_Invalid_Float_Nan_underscore(t *testing.T) {
624 input := "nan_underscore = na_n\n"
625 testgenInvalid(t, input)
626 }
627
628 func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingPointMin(t *testing.T) {
629 input := "trailing-point-min = -1.\n"
630 testgenInvalid(t, input)
631 }
632
633 func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingPointPlus(t *testing.T) {
634 input := "trailing-point-plus = +1.\n"
635 testgenInvalid(t, input)
636 }
637
638 func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingPoint(t *testing.T) {
639 input := "trailing-point = 1.\n"
640 testgenInvalid(t, input)
641 }
642
643 func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUsExp1(t *testing.T) {
644 input := "trailing-us-exp-1 = 1_e2\n"
645 testgenInvalid(t, input)
646 }
647
648 func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUsExp2(t *testing.T) {
649 input := "trailing-us-exp-2 = 1.2_e2\n"
650 testgenInvalid(t, input)
651 }
652
653 func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUs(t *testing.T) {
654 input := "trailing-us = 1.2_\n"
655 testgenInvalid(t, input)
656 }
657
658 func TestTOMLTest_Invalid_Tests_Invalid_Float_UsAfterPoint(t *testing.T) {
659 input := "us-after-point = 1._2\n"
660 testgenInvalid(t, input)
661 }
662
663 func TestTOMLTest_Invalid_Tests_Invalid_Float_UsBeforePoint(t *testing.T) {
664 input := "us-before-point = 1_.2\n"
665 testgenInvalid(t, input)
666 }
667
668 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_BadKeySyntax(t *testing.T) {
669 input := "tbl = { a = 1, [b] }\n"
670 testgenInvalid(t, input)
671 }
672
673 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DoubleComma(t *testing.T) {
674 input := "t = {x=3,,y=4}\n"
675 testgenInvalid(t, input)
676 }
677
678 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey1(t *testing.T) {
679 input := "# Duplicate keys within an inline table are invalid\na={b=1, b=2}\n"
680 testgenInvalid(t, input)
681 }
682
683 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey2(t *testing.T) {
684 input := "table1 = { table2.dupe = 1, table2.dupe = 2 }\n"
685 testgenInvalid(t, input)
686 }
687
688 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey3(t *testing.T) {
689 input := "tbl = { fruit = { apple.color = \"red\" }, fruit.apple.texture = { smooth = true } }\n\n"
690 testgenInvalid(t, input)
691 }
692
693 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey4(t *testing.T) {
694 input := "tbl = { a.b = \"a_b\", a.b.c = \"a_b_c\" }\n"
695 testgenInvalid(t, input)
696 }
697
698 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty1(t *testing.T) {
699 input := "t = {,}\n"
700 testgenInvalid(t, input)
701 }
702
703 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty2(t *testing.T) {
704 input := "t = {,\n}\n"
705 testgenInvalid(t, input)
706 }
707
708 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty3(t *testing.T) {
709 input := "t = {\n,\n}\n"
710 testgenInvalid(t, input)
711 }
712
713 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Linebreak1(t *testing.T) {
714 input := "# No newlines are allowed between the curly braces unless they are valid within\n# a value.\nsimple = { a = 1 \n}\n"
715 testgenInvalid(t, input)
716 }
717
718 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Linebreak2(t *testing.T) {
719 input := "t = {a=1,\nb=2}\n"
720 testgenInvalid(t, input)
721 }
722
723 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Linebreak3(t *testing.T) {
724 input := "t = {a=1\n,b=2}\n"
725 testgenInvalid(t, input)
726 }
727
728 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Linebreak4(t *testing.T) {
729 input := "json_like = {\n first = \"Tom\",\n last = \"Preston-Werner\"\n}\n"
730 testgenInvalid(t, input)
731 }
732
733 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoClose1(t *testing.T) {
734 input := "a={\n"
735 testgenInvalid(t, input)
736 }
737
738 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoClose2(t *testing.T) {
739 input := "a={b=1\n"
740 testgenInvalid(t, input)
741 }
742
743 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoComma1(t *testing.T) {
744 input := "t = {x = 3 y = 4}\n"
745 testgenInvalid(t, input)
746 }
747
748 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoComma2(t *testing.T) {
749 input := "arrr = { comma-missing = true valid-toml = false }\n"
750 testgenInvalid(t, input)
751 }
752
753 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite1(t *testing.T) {
754 input := "a.b=0\n# Since table \"a\" is already defined, it can't be replaced by an inline table.\na={}\n"
755 testgenInvalid(t, input)
756 }
757
758 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite2(t *testing.T) {
759 input := "a={}\n# Inline tables are immutable and can't be extended\n[a.b]\n"
760 testgenInvalid(t, input)
761 }
762
763 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite3(t *testing.T) {
764 input := "a = { b = 1 }\na.b = 2\n"
765 testgenInvalid(t, input)
766 }
767
768 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite4(t *testing.T) {
769 input := "inline-t = { nest = {} }\n\n[[inline-t.nest]]\n"
770 testgenInvalid(t, input)
771 }
772
773 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite5(t *testing.T) {
774 input := "inline-t = { nest = {} }\n\n[inline-t.nest]\n"
775 testgenInvalid(t, input)
776 }
777
778 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite6(t *testing.T) {
779 input := "a = { b = 1, b.c = 2 }\n"
780 testgenInvalid(t, input)
781 }
782
783 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite7(t *testing.T) {
784 input := "tab = { inner.table = [{}], inner.table.val = \"bad\" }"
785 testgenInvalid(t, input)
786 }
787
788 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite8(t *testing.T) {
789 input := "tab = { inner = { dog = \"best\" }, inner.cat = \"worst\" }"
790 testgenInvalid(t, input)
791 }
792
793 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite9(t *testing.T) {
794 input := "[tab.nested]\ninline-t = { nest = {} }\n\n[tab]\nnested.inline-t.nest = 2\n"
795 testgenInvalid(t, input)
796 }
797
798 func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_TrailingComma(t *testing.T) {
799 input := "# A terminating comma (also called trailing comma) is not permitted after the\n# last key/value pair in an inline table\nabc = { abc = 123, }\n"
800 testgenInvalid(t, input)
801 }
802
803 func TestTOMLTest_Invalid_Tests_Invalid_Integer_CapitalBin(t *testing.T) {
804 input := "capital-bin = 0B0\n"
805 testgenInvalid(t, input)
806 }
807
808 func TestTOMLTest_Invalid_Tests_Invalid_Integer_CapitalHex(t *testing.T) {
809 input := "capital-hex = 0X1\n"
810 testgenInvalid(t, input)
811 }
812
813 func TestTOMLTest_Invalid_Tests_Invalid_Integer_CapitalOct(t *testing.T) {
814 input := "capital-oct = 0O0\n"
815 testgenInvalid(t, input)
816 }
817
818 func TestTOMLTest_Invalid_Tests_Invalid_Integer_DoubleSignNex(t *testing.T) {
819 input := "double-sign-nex = --99\n"
820 testgenInvalid(t, input)
821 }
822
823 func TestTOMLTest_Invalid_Tests_Invalid_Integer_DoubleSignPlus(t *testing.T) {
824 input := "double-sign-plus = ++99\n"
825 testgenInvalid(t, input)
826 }
827
828 func TestTOMLTest_Invalid_Tests_Invalid_Integer_DoubleUs(t *testing.T) {
829 input := "double-us = 1__23\n"
830 testgenInvalid(t, input)
831 }
832
833 func TestTOMLTest_Invalid_Tests_Invalid_Integer_IncompleteBin(t *testing.T) {
834 input := "incomplete-bin = 0b\n"
835 testgenInvalid(t, input)
836 }
837
838 func TestTOMLTest_Invalid_Tests_Invalid_Integer_IncompleteHex(t *testing.T) {
839 input := "incomplete-hex = 0x\n"
840 testgenInvalid(t, input)
841 }
842
843 func TestTOMLTest_Invalid_Tests_Invalid_Integer_IncompleteOct(t *testing.T) {
844 input := "incomplete-oct = 0o\n"
845 testgenInvalid(t, input)
846 }
847
848 func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidBin(t *testing.T) {
849 input := "invalid-bin = 0b0012\n"
850 testgenInvalid(t, input)
851 }
852
853 func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex1(t *testing.T) {
854 input := "invalid-hex-1 = 0xaafz\n"
855 testgenInvalid(t, input)
856 }
857
858 func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex2(t *testing.T) {
859 input := "invalid-hex-2 = 0xgabba00f1\n"
860 testgenInvalid(t, input)
861 }
862
863 func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex(t *testing.T) {
864 input := "invalid-hex = 0xaafz\n"
865 testgenInvalid(t, input)
866 }
867
868 func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidOct(t *testing.T) {
869 input := "invalid-oct = 0o778\n"
870 testgenInvalid(t, input)
871 }
872
873 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingUsBin(t *testing.T) {
874 input := "leading-us-bin = _0b1\n"
875 testgenInvalid(t, input)
876 }
877
878 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingUsHex(t *testing.T) {
879 input := "leading-us-hex = _0x1\n"
880 testgenInvalid(t, input)
881 }
882
883 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingUsOct(t *testing.T) {
884 input := "leading-us-oct = _0o1\n"
885 testgenInvalid(t, input)
886 }
887
888 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingUs(t *testing.T) {
889 input := "leading-us = _123\n"
890 testgenInvalid(t, input)
891 }
892
893 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero1(t *testing.T) {
894 input := "leading-zero-1 = 01\n"
895 testgenInvalid(t, input)
896 }
897
898 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero2(t *testing.T) {
899 input := "leading-zero-2 = 00\n"
900 testgenInvalid(t, input)
901 }
902
903 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero3(t *testing.T) {
904 input := "leading-zero-3 = 0_0\n"
905 testgenInvalid(t, input)
906 }
907
908 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign1(t *testing.T) {
909 input := "leading-zero-sign-1 = -01\n"
910 testgenInvalid(t, input)
911 }
912
913 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign2(t *testing.T) {
914 input := "leading-zero-sign-2 = +01\n"
915 testgenInvalid(t, input)
916 }
917
918 func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign3(t *testing.T) {
919 input := "leading-zero-sign-3 = +0_1\n"
920 testgenInvalid(t, input)
921 }
922
923 func TestTOMLTest_Invalid_Tests_Invalid_Integer_NegativeBin(t *testing.T) {
924 input := "negative-bin = -0b11010110\n"
925 testgenInvalid(t, input)
926 }
927
928 func TestTOMLTest_Invalid_Tests_Invalid_Integer_NegativeHex(t *testing.T) {
929 input := "negative-hex = -0xff\n"
930 testgenInvalid(t, input)
931 }
932
933 func TestTOMLTest_Invalid_Tests_Invalid_Integer_NegativeOct(t *testing.T) {
934 input := "negative-oct = -0o755\n"
935 testgenInvalid(t, input)
936 }
937
938 func TestTOMLTest_Invalid_Tests_Invalid_Integer_PositiveBin(t *testing.T) {
939 input := "positive-bin = +0b11010110\n"
940 testgenInvalid(t, input)
941 }
942
943 func TestTOMLTest_Invalid_Tests_Invalid_Integer_PositiveHex(t *testing.T) {
944 input := "positive-hex = +0xff\n"
945 testgenInvalid(t, input)
946 }
947
948 func TestTOMLTest_Invalid_Tests_Invalid_Integer_PositiveOct(t *testing.T) {
949 input := "positive-oct = +0o755\n"
950 testgenInvalid(t, input)
951 }
952
953 func TestTOMLTest_Invalid_Tests_Invalid_Integer_TextAfterInteger(t *testing.T) {
954 input := "answer = 42 the ultimate answer?\n"
955 testgenInvalid(t, input)
956 }
957
958 func TestTOMLTest_Invalid_Tests_Invalid_Integer_TrailingUsBin(t *testing.T) {
959 input := "trailing-us-bin = 0b1_\n"
960 testgenInvalid(t, input)
961 }
962
963 func TestTOMLTest_Invalid_Tests_Invalid_Integer_TrailingUsHex(t *testing.T) {
964 input := "trailing-us-hex = 0x1_\n"
965 testgenInvalid(t, input)
966 }
967
968 func TestTOMLTest_Invalid_Tests_Invalid_Integer_TrailingUsOct(t *testing.T) {
969 input := "trailing-us-oct = 0o1_\n"
970 testgenInvalid(t, input)
971 }
972
973 func TestTOMLTest_Invalid_Tests_Invalid_Integer_TrailingUs(t *testing.T) {
974 input := "trailing-us = 123_\n"
975 testgenInvalid(t, input)
976 }
977
978 func TestTOMLTest_Invalid_Tests_Invalid_Integer_UsAfterBin(t *testing.T) {
979 input := "us-after-bin = 0b_1\n"
980 testgenInvalid(t, input)
981 }
982
983 func TestTOMLTest_Invalid_Tests_Invalid_Integer_UsAfterHex(t *testing.T) {
984 input := "us-after-hex = 0x_1\n"
985 testgenInvalid(t, input)
986 }
987
988 func TestTOMLTest_Invalid_Tests_Invalid_Integer_UsAfterOct(t *testing.T) {
989 input := "us-after-oct = 0o_1\n"
990 testgenInvalid(t, input)
991 }
992
993 func TestTOMLTest_Invalid_Tests_Invalid_Key_AfterArray(t *testing.T) {
994 input := "[[agencies]] owner = \"S Cjelli\"\n"
995 testgenInvalid(t, input)
996 }
997
998 func TestTOMLTest_Invalid_Tests_Invalid_Key_AfterTable(t *testing.T) {
999 input := "[error] this = \"should not be here\"\n"
1000 testgenInvalid(t, input)
1001 }
1002
1003 func TestTOMLTest_Invalid_Tests_Invalid_Key_AfterValue(t *testing.T) {
1004 input := "first = \"Tom\" last = \"Preston-Werner\" # INVALID\n"
1005 testgenInvalid(t, input)
1006 }
1007
1008 func TestTOMLTest_Invalid_Tests_Invalid_Key_BareInvalidCharacter(t *testing.T) {
1009 input := "bare!key = 123\n"
1010 testgenInvalid(t, input)
1011 }
1012
1013 func TestTOMLTest_Invalid_Tests_Invalid_Key_DottedRedefineTable1(t *testing.T) {
1014 input := "a = false\na.b = true\n"
1015 testgenInvalid(t, input)
1016 }
1017
1018 func TestTOMLTest_Invalid_Tests_Invalid_Key_DottedRedefineTable2(t *testing.T) {
1019 input := "# Defined a.b as int\na.b = 1\n# Tries to access it as table: error\na.b.c = 2\n"
1020 testgenInvalid(t, input)
1021 }
1022
1023 func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys(t *testing.T) {
1024 input := "dupe = false\ndupe = true\n"
1025 testgenInvalid(t, input)
1026 }
1027
1028 func TestTOMLTest_Invalid_Tests_Invalid_Key_Duplicate(t *testing.T) {
1029 input := "# DO NOT DO THIS\nname = \"Tom\"\nname = \"Pradyun\"\n"
1030 testgenInvalid(t, input)
1031 }
1032
1033 func TestTOMLTest_Invalid_Tests_Invalid_Key_Empty(t *testing.T) {
1034 input := " = 1\n"
1035 testgenInvalid(t, input)
1036 }
1037
1038 func TestTOMLTest_Invalid_Tests_Invalid_Key_EndInEscape(t *testing.T) {
1039 input := "\"backslash is the last char\\\n"
1040 testgenInvalid(t, input)
1041 }
1042
1043 func TestTOMLTest_Invalid_Tests_Invalid_Key_Escape(t *testing.T) {
1044 input := "\\u00c0 = \"latin capital letter A with grave\"\n"
1045 testgenInvalid(t, input)
1046 }
1047
1048 func TestTOMLTest_Invalid_Tests_Invalid_Key_Hash(t *testing.T) {
1049 input := "a# = 1\n"
1050 testgenInvalid(t, input)
1051 }
1052
1053 func TestTOMLTest_Invalid_Tests_Invalid_Key_Multiline(t *testing.T) {
1054 input := "\"\"\"long\nkey\"\"\" = 1\n"
1055 testgenInvalid(t, input)
1056 }
1057
1058 func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline(t *testing.T) {
1059 input := "barekey\n = 123\n"
1060 testgenInvalid(t, input)
1061 }
1062
1063 func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol(t *testing.T) {
1064 input := "a = 1 b = 2\n"
1065 testgenInvalid(t, input)
1066 }
1067
1068 func TestTOMLTest_Invalid_Tests_Invalid_Key_OpenBracket(t *testing.T) {
1069 input := "[abc = 1\n"
1070 testgenInvalid(t, input)
1071 }
1072
1073 func TestTOMLTest_Invalid_Tests_Invalid_Key_PartialQuoted(t *testing.T) {
1074 input := "partial\"quoted\" = 5\n"
1075 testgenInvalid(t, input)
1076 }
1077
1078 func TestTOMLTest_Invalid_Tests_Invalid_Key_QuotedUnclosed1(t *testing.T) {
1079 input := "\"key = x\n"
1080 testgenInvalid(t, input)
1081 }
1082
1083 func TestTOMLTest_Invalid_Tests_Invalid_Key_QuotedUnclosed2(t *testing.T) {
1084 input := "\"key\n"
1085 testgenInvalid(t, input)
1086 }
1087
1088 func TestTOMLTest_Invalid_Tests_Invalid_Key_SingleOpenBracket(t *testing.T) {
1089 input := "[\n"
1090 testgenInvalid(t, input)
1091 }
1092
1093 func TestTOMLTest_Invalid_Tests_Invalid_Key_Space(t *testing.T) {
1094 input := "a b = 1\n"
1095 testgenInvalid(t, input)
1096 }
1097
1098 func TestTOMLTest_Invalid_Tests_Invalid_Key_SpecialCharacter(t *testing.T) {
1099 input := "μ = \"greek small letter mu\"\n"
1100 testgenInvalid(t, input)
1101 }
1102
1103 func TestTOMLTest_Invalid_Tests_Invalid_Key_StartBracket(t *testing.T) {
1104 input := "[a]\n[xyz = 5\n[b]\n"
1105 testgenInvalid(t, input)
1106 }
1107
1108 func TestTOMLTest_Invalid_Tests_Invalid_Key_StartDot(t *testing.T) {
1109 input := ".key = 1\n"
1110 testgenInvalid(t, input)
1111 }
1112
1113 func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals(t *testing.T) {
1114 input := "key= = 1\n"
1115 testgenInvalid(t, input)
1116 }
1117
1118 func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals2(t *testing.T) {
1119 input := "a==1\n"
1120 testgenInvalid(t, input)
1121 }
1122
1123 func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals3(t *testing.T) {
1124 input := "a=b=1\n"
1125 testgenInvalid(t, input)
1126 }
1127
1128 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue1(t *testing.T) {
1129 input := "key\n"
1130 testgenInvalid(t, input)
1131 }
1132
1133 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue2(t *testing.T) {
1134 input := "key = \n"
1135 testgenInvalid(t, input)
1136 }
1137
1138 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue3(t *testing.T) {
1139 input := "\"key\"\n"
1140 testgenInvalid(t, input)
1141 }
1142
1143 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue4(t *testing.T) {
1144 input := "\"key\" = \n"
1145 testgenInvalid(t, input)
1146 }
1147
1148 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue5(t *testing.T) {
1149 input := "fs.fw\n"
1150 testgenInvalid(t, input)
1151 }
1152
1153 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue6(t *testing.T) {
1154 input := "fs.fw =\n"
1155 testgenInvalid(t, input)
1156 }
1157
1158 func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue7(t *testing.T) {
1159 input := "fs.\n"
1160 testgenInvalid(t, input)
1161 }
1162
1163 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_Feb29(t *testing.T) {
1164 input := "\"not a leap year\" = 2100-02-29\n"
1165 testgenInvalid(t, input)
1166 }
1167
1168 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_Feb30(t *testing.T) {
1169 input := "\"only 28 or 29 days in february\" = 1988-02-30\n\n"
1170 testgenInvalid(t, input)
1171 }
1172
1173 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_MdayOver(t *testing.T) {
1174 input := "# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on\n# ; month/year\nd = 2006-01-32\n"
1175 testgenInvalid(t, input)
1176 }
1177
1178 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_MdayUnder(t *testing.T) {
1179 input := "# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on\n# ; month/year\nd = 2006-01-00\n"
1180 testgenInvalid(t, input)
1181 }
1182
1183 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_MonthOver(t *testing.T) {
1184 input := "# date-month = 2DIGIT ; 01-12\nd = 2006-13-01\n"
1185 testgenInvalid(t, input)
1186 }
1187
1188 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_MonthUnder(t *testing.T) {
1189 input := "# date-month = 2DIGIT ; 01-12\nd = 2007-00-01\n"
1190 testgenInvalid(t, input)
1191 }
1192
1193 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_NoLeadsWithMilli(t *testing.T) {
1194 input := "# Day \"5\" instead of \"05\"; the leading zero is required.\nwith-milli = 1987-07-5\n"
1195 testgenInvalid(t, input)
1196 }
1197
1198 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_NoLeads(t *testing.T) {
1199 input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05\n"
1200 testgenInvalid(t, input)
1201 }
1202
1203 func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_TrailingT(t *testing.T) {
1204 input := "# Date cannot end with trailing T\nd = 2006-01-30T\n"
1205 testgenInvalid(t, input)
1206 }
1207
1208 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_Feb29(t *testing.T) {
1209 input := "\"not a leap year\" = 2100-02-29T15:15:15\n"
1210 testgenInvalid(t, input)
1211 }
1212
1213 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_Feb30(t *testing.T) {
1214 input := "\"only 28 or 29 days in february\" = 1988-02-30T15:15:15\n\n"
1215 testgenInvalid(t, input)
1216 }
1217
1218 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_HourOver(t *testing.T) {
1219 input := "# time-hour = 2DIGIT ; 00-23\nd = 2006-01-01T24:00:00\n"
1220 testgenInvalid(t, input)
1221 }
1222
1223 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_MdayOver(t *testing.T) {
1224 input := "# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on\n# ; month/year\nd = 2006-01-32T00:00:00\n"
1225 testgenInvalid(t, input)
1226 }
1227
1228 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_MdayUnder(t *testing.T) {
1229 input := "# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on\n# ; month/year\nd = 2006-01-00T00:00:00\n"
1230 testgenInvalid(t, input)
1231 }
1232
1233 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_MinuteOver(t *testing.T) {
1234 input := "# time-minute = 2DIGIT ; 00-59\nd = 2006-01-01T00:60:00\n"
1235 testgenInvalid(t, input)
1236 }
1237
1238 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_MonthOver(t *testing.T) {
1239 input := "# date-month = 2DIGIT ; 01-12\nd = 2006-13-01T00:00:00\n"
1240 testgenInvalid(t, input)
1241 }
1242
1243 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_MonthUnder(t *testing.T) {
1244 input := "# date-month = 2DIGIT ; 01-12\nd = 2007-00-01T00:00:00\n"
1245 testgenInvalid(t, input)
1246 }
1247
1248 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoLeadsWithMilli(t *testing.T) {
1249 input := "# Day \"5\" instead of \"05\"; the leading zero is required.\nwith-milli = 1987-07-5T17:45:00.12\n"
1250 testgenInvalid(t, input)
1251 }
1252
1253 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoLeads(t *testing.T) {
1254 input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05T17:45:00\n"
1255 testgenInvalid(t, input)
1256 }
1257
1258 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoSecs(t *testing.T) {
1259 input := "# No seconds in time.\nno-secs = 1987-07-05T17:45\n"
1260 testgenInvalid(t, input)
1261 }
1262
1263 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoT(t *testing.T) {
1264 input := "# No \"t\" or \"T\" between the date and time.\nno-t = 1987-07-0517:45:00\n"
1265 testgenInvalid(t, input)
1266 }
1267
1268 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_SecondOver(t *testing.T) {
1269 input := "# time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second\n# ; rules\nd = 2006-01-01T00:00:61\n"
1270 testgenInvalid(t, input)
1271 }
1272
1273 func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_TimeNoLeads(t *testing.T) {
1274 input := "# Leading 0 is always required.\nd = 2023-10-01T1:32:00Z\n"
1275 testgenInvalid(t, input)
1276 }
1277
1278 func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_HourOver(t *testing.T) {
1279 input := "# time-hour = 2DIGIT ; 00-23\nd = 24:00:00\n"
1280 testgenInvalid(t, input)
1281 }
1282
1283 func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_MinuteOver(t *testing.T) {
1284 input := "# time-minute = 2DIGIT ; 00-59\nd = 00:60:00\n"
1285 testgenInvalid(t, input)
1286 }
1287
1288 func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_NoSecs(t *testing.T) {
1289 input := "# No seconds in time.\nno-secs = 17:45\n"
1290 testgenInvalid(t, input)
1291 }
1292
1293 func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_SecondOver(t *testing.T) {
1294 input := "# time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second\n# ; rules\nd = 00:00:61\n"
1295 testgenInvalid(t, input)
1296 }
1297
1298 func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TimeNoLeads2(t *testing.T) {
1299 input := "# Leading 0 is always required.\nd = 01:32:0\n"
1300 testgenInvalid(t, input)
1301 }
1302
1303 func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TimeNoLeads(t *testing.T) {
1304 input := "# Leading 0 is always required.\nd = 1:32:00\n"
1305 testgenInvalid(t, input)
1306 }
1307
1308 func TestTOMLTest_Invalid_Tests_Invalid_Spec_InlineTable20(t *testing.T) {
1309 input := "[product]\ntype = { name = \"Nail\" }\ntype.edible = false # INVALID\n"
1310 testgenInvalid(t, input)
1311 }
1312
1313 func TestTOMLTest_Invalid_Tests_Invalid_Spec_InlineTable30(t *testing.T) {
1314 input := "[product]\ntype.name = \"Nail\"\ntype = { edible = false } # INVALID\n"
1315 testgenInvalid(t, input)
1316 }
1317
1318 func TestTOMLTest_Invalid_Tests_Invalid_Spec_KeyValuePair1(t *testing.T) {
1319 input := "key = # INVALID\n"
1320 testgenInvalid(t, input)
1321 }
1322
1323 func TestTOMLTest_Invalid_Tests_Invalid_Spec_Keys2(t *testing.T) {
1324 input := "= \"no key name\" # INVALID\n\"\" = \"blank\" # VALID but discouraged\n'' = 'blank' # VALID but discouraged\n"
1325 testgenInvalid(t, input)
1326 }
1327
1328 func TestTOMLTest_Invalid_Tests_Invalid_Spec_String40(t *testing.T) {
1329 input := "str4 = \"\"\"Here are two quotation marks: \"\". Simple enough.\"\"\"\nstr5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\" # INVALID\nstr5 = \"\"\"Here are three quotation marks: \"\"\\\".\"\"\"\nstr6 = \"\"\"Here are fifteen quotation marks: \"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\".\"\"\"\n\n# \"This,\" she said, \"is just a pointless statement.\"\nstr7 = \"\"\"\"This,\" she said, \"is just a pointless statement.\"\"\"\"\n"
1330 testgenInvalid(t, input)
1331 }
1332
1333 func TestTOMLTest_Invalid_Tests_Invalid_Spec_String70(t *testing.T) {
1334 input := "quot15 = '''Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"'''\n\napos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID\napos15 = \"Here are fifteen apostrophes: '''''''''''''''\"\n\n# 'That,' she said, 'is still pointless.'\nstr = ''''That,' she said, 'is still pointless.''''\n"
1335 testgenInvalid(t, input)
1336 }
1337
1338 func TestTOMLTest_Invalid_Tests_Invalid_Spec_Table90(t *testing.T) {
1339 input := "[fruit]\napple.color = \"red\"\napple.taste.sweet = true\n\n[fruit.apple] # INVALID\n# [fruit.apple.taste] # INVALID\n\n[fruit.apple.texture] # you can add sub-tables\nsmooth = true\n"
1340 testgenInvalid(t, input)
1341 }
1342
1343 func TestTOMLTest_Invalid_Tests_Invalid_Spec_Table91(t *testing.T) {
1344 input := "[fruit]\napple.color = \"red\"\napple.taste.sweet = true\n\n# [fruit.apple] # INVALID\n[fruit.apple.taste] # INVALID\n\n[fruit.apple.texture] # you can add sub-tables\nsmooth = true\n"
1345 testgenInvalid(t, input)
1346 }
1347
1348 func TestTOMLTest_Invalid_Tests_Invalid_String_BadByteEscape(t *testing.T) {
1349 input := "naughty = \"\\xAg\"\n"
1350 testgenInvalid(t, input)
1351 }
1352
1353 func TestTOMLTest_Invalid_Tests_Invalid_String_BadConcat(t *testing.T) {
1354 input := "no_concat = \"first\" \"second\"\n"
1355 testgenInvalid(t, input)
1356 }
1357
1358 func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape1(t *testing.T) {
1359 input := "invalid-escape = \"This string has a bad \\a escape character.\"\n"
1360 testgenInvalid(t, input)
1361 }
1362
1363 func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape2(t *testing.T) {
1364 input := "invalid-escape = \"This string has a bad \\ escape character.\"\n\n"
1365 testgenInvalid(t, input)
1366 }
1367
1368 func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape3(t *testing.T) {
1369 input := "backslash = \"\\\"\n"
1370 testgenInvalid(t, input)
1371 }
1372
1373 func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc1(t *testing.T) {
1374 input := "bad-hex-esc-1 = \"\\x0g\"\n"
1375 testgenInvalid(t, input)
1376 }
1377
1378 func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc2(t *testing.T) {
1379 input := "bad-hex-esc-2 = \"\\xG0\"\n"
1380 testgenInvalid(t, input)
1381 }
1382
1383 func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc3(t *testing.T) {
1384 input := "bad-hex-esc-3 = \"\\x\"\n"
1385 testgenInvalid(t, input)
1386 }
1387
1388 func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc4(t *testing.T) {
1389 input := "bad-hex-esc-4 = \"\\x 50\"\n"
1390 testgenInvalid(t, input)
1391 }
1392
1393 func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc5(t *testing.T) {
1394 input := "bad-hex-esc-5 = \"\\x 50\"\n"
1395 testgenInvalid(t, input)
1396 }
1397
1398 func TestTOMLTest_Invalid_Tests_Invalid_String_BadMultiline(t *testing.T) {
1399 input := "multi = \"first line\nsecond line\"\n"
1400 testgenInvalid(t, input)
1401 }
1402
1403 func TestTOMLTest_Invalid_Tests_Invalid_String_BadSlashEscape(t *testing.T) {
1404 input := "invalid-escape = \"This string has a bad \\/ escape character.\"\n"
1405 testgenInvalid(t, input)
1406 }
1407
1408 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc1(t *testing.T) {
1409 input := "bad-uni-esc-1 = \"val\\ue\"\n"
1410 testgenInvalid(t, input)
1411 }
1412
1413 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc2(t *testing.T) {
1414 input := "bad-uni-esc-2 = \"val\\Ux\"\n"
1415 testgenInvalid(t, input)
1416 }
1417
1418 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc3(t *testing.T) {
1419 input := "bad-uni-esc-3 = \"val\\U0000000\"\n"
1420 testgenInvalid(t, input)
1421 }
1422
1423 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc4(t *testing.T) {
1424 input := "bad-uni-esc-4 = \"val\\U0000\"\n"
1425 testgenInvalid(t, input)
1426 }
1427
1428 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc5(t *testing.T) {
1429 input := "bad-uni-esc-5 = \"val\\Ugggggggg\"\n"
1430 testgenInvalid(t, input)
1431 }
1432
1433 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc6(t *testing.T) {
1434 input := "bad-uni-esc-6 = \"This string contains a non scalar unicode codepoint \\uD801\"\n"
1435 testgenInvalid(t, input)
1436 }
1437
1438 func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc7(t *testing.T) {
1439 input := "bad-uni-esc-7 = \"\\uabag\"\n"
1440 testgenInvalid(t, input)
1441 }
1442
1443 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicByteEscapes(t *testing.T) {
1444 input := "answer = \"\\x33\"\n"
1445 testgenInvalid(t, input)
1446 }
1447
1448 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape1(t *testing.T) {
1449 input := "a = \"\"\"\\UFFFFFFFF\"\"\"\n"
1450 testgenInvalid(t, input)
1451 }
1452
1453 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape2(t *testing.T) {
1454 input := "a = \"\"\"\\U00D80000\"\"\"\n"
1455 testgenInvalid(t, input)
1456 }
1457
1458 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineQuotes(t *testing.T) {
1459 input := "str5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\"\n"
1460 testgenInvalid(t, input)
1461 }
1462
1463 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineUnknownEscape(t *testing.T) {
1464 input := "a = \"\"\"\\@\"\"\"\n"
1465 testgenInvalid(t, input)
1466 }
1467
1468 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicOutOfRangeUnicodeEscape1(t *testing.T) {
1469 input := "a = \"\\UFFFFFFFF\"\n"
1470 testgenInvalid(t, input)
1471 }
1472
1473 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicOutOfRangeUnicodeEscape2(t *testing.T) {
1474 input := "a = \"\\U00D80000\"\n"
1475 testgenInvalid(t, input)
1476 }
1477
1478 func TestTOMLTest_Invalid_Tests_Invalid_String_BasicUnknownEscape(t *testing.T) {
1479 input := "a = \"\\@\"\n"
1480 testgenInvalid(t, input)
1481 }
1482
1483 func TestTOMLTest_Invalid_Tests_Invalid_String_LiteralMultilineQuotes1(t *testing.T) {
1484 input := "a = '''6 apostrophes: ''''''\n\n"
1485 testgenInvalid(t, input)
1486 }
1487
1488 func TestTOMLTest_Invalid_Tests_Invalid_String_LiteralMultilineQuotes2(t *testing.T) {
1489 input := "a = '''15 apostrophes: ''''''''''''''''''\n"
1490 testgenInvalid(t, input)
1491 }
1492
1493 func TestTOMLTest_Invalid_Tests_Invalid_String_MissingQuotes(t *testing.T) {
1494 input := "name = value\n"
1495 testgenInvalid(t, input)
1496 }
1497
1498 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape1(t *testing.T) {
1499 input := "k = \"\"\"t\\a\"\"\"\n\n"
1500 testgenInvalid(t, input)
1501 }
1502
1503 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape2(t *testing.T) {
1504 input := "# \\<Space> is not a valid escape.\nk = \"\"\"t\\ t\"\"\"\n"
1505 testgenInvalid(t, input)
1506 }
1507
1508 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape3(t *testing.T) {
1509 input := "# \\<Space> is not a valid escape.\nk = \"\"\"t\\ \"\"\"\n\n"
1510 testgenInvalid(t, input)
1511 }
1512
1513 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape4(t *testing.T) {
1514 input := "backslash = \"\"\"\\\"\"\"\n"
1515 testgenInvalid(t, input)
1516 }
1517
1518 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineEscapeSpace1(t *testing.T) {
1519 input := "a = \"\"\"\n foo \\ \\n\n bar\"\"\"\n"
1520 testgenInvalid(t, input)
1521 }
1522
1523 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineEscapeSpace2(t *testing.T) {
1524 input := "bee = \"\"\"\nhee \\\n\ngee \\ \"\"\"\n"
1525 testgenInvalid(t, input)
1526 }
1527
1528 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose1(t *testing.T) {
1529 input := "invalid = '''\n this will fail\n"
1530 testgenInvalid(t, input)
1531 }
1532
1533 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose2(t *testing.T) {
1534 input := "x='''\n"
1535 testgenInvalid(t, input)
1536 }
1537
1538 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose3(t *testing.T) {
1539 input := "not-closed= '''\ndiibaa\nblibae ete\neteta\n"
1540 testgenInvalid(t, input)
1541 }
1542
1543 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose4(t *testing.T) {
1544 input := "bee = '''\nhee\ngee ''\n"
1545 testgenInvalid(t, input)
1546 }
1547
1548 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose1(t *testing.T) {
1549 input := "invalid = \"\"\"\n this will fail\n"
1550 testgenInvalid(t, input)
1551 }
1552
1553 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose2(t *testing.T) {
1554 input := "x=\"\"\"\n"
1555 testgenInvalid(t, input)
1556 }
1557
1558 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose3(t *testing.T) {
1559 input := "not-closed= \"\"\"\ndiibaa\nblibae ete\neteta\n"
1560 testgenInvalid(t, input)
1561 }
1562
1563 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose4(t *testing.T) {
1564 input := "bee = \"\"\"\nhee\ngee \"\"\n"
1565 testgenInvalid(t, input)
1566 }
1567
1568 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose5(t *testing.T) {
1569 input := "bee = \"\"\"\nhee\ngee\\\t \n"
1570 testgenInvalid(t, input)
1571 }
1572
1573 func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineQuotes1(t *testing.T) {
1574 input := "a = \"\"\"6 quotes: \"\"\"\"\"\"\n"
1575 testgenInvalid(t, input)
1576 }
1577
1578 func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose1(t *testing.T) {
1579 input := "no-ending-quote = \"One time, at band camp\n"
1580 testgenInvalid(t, input)
1581 }
1582
1583 func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose2(t *testing.T) {
1584 input := "\"a-string\".must-be = \"closed\n"
1585 testgenInvalid(t, input)
1586 }
1587
1588 func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose3(t *testing.T) {
1589 input := "no-ending-quote = 'One time, at band camp\n"
1590 testgenInvalid(t, input)
1591 }
1592
1593 func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose4(t *testing.T) {
1594 input := "'a-string'.must-be = 'closed\n"
1595 testgenInvalid(t, input)
1596 }
1597
1598 func TestTOMLTest_Invalid_Tests_Invalid_String_TextAfterString(t *testing.T) {
1599 input := "string = \"Is there life after strings?\" No.\n"
1600 testgenInvalid(t, input)
1601 }
1602
1603 func TestTOMLTest_Invalid_Tests_Invalid_String_WrongClose(t *testing.T) {
1604 input := "bad-ending-quote = \"double and single'\n"
1605 testgenInvalid(t, input)
1606 }
1607
1608 func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendToArrayWithDottedKeys(t *testing.T) {
1609 input := "[[a.b]]\n\n[a]\nb.y = 2\n"
1610 testgenInvalid(t, input)
1611 }
1612
1613 func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys1(t *testing.T) {
1614 input := "# First a.b.c defines a table: a.b.c = {z=9}\n#\n# Then we define a.b.c.t = \"str\" to add a str to the above table, making it:\n#\n# a.b.c = {z=9, t=\"...\"}\n#\n# While this makes sense, logically, it was decided this is not valid TOML as\n# it's too confusing/convoluted.\n# \n# See: https://github.com/toml-lang/toml/issues/846\n# https://github.com/toml-lang/toml/pull/859\n\n[a.b.c]\n z = 9\n\n[a]\n b.c.t = \"Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed\"\n"
1615 testgenInvalid(t, input)
1616 }
1617
1618 func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys2(t *testing.T) {
1619 input := "# This is the same issue as in injection-1.toml, except that nests one level\n# deeper. See that file for a more complete description.\n\n[a.b.c.d]\n z = 9\n\n[a]\n b.c.d.k.t = \"Using dotted keys to add to [a.b.c.d] after explicitly defining it above is not allowed\"\n"
1620 testgenInvalid(t, input)
1621 }
1622
1623 func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayEmpty(t *testing.T) {
1624 input := "[[]]\nname = \"Born to Run\"\n"
1625 testgenInvalid(t, input)
1626 }
1627
1628 func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayImplicit(t *testing.T) {
1629 input := "# This test is a bit tricky. It should fail because the first use of\n# `[[albums.songs]]` without first declaring `albums` implies that `albums`\n# must be a table. The alternative would be quite weird. Namely, it wouldn't\n# comply with the TOML spec: \"Each double-bracketed sub-table will belong to \n# the most *recently* defined table element *above* it.\"\n#\n# This is in contrast to the *valid* test, table-array-implicit where\n# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared\n# later. (Although, `[albums]` could be.)\n[[albums.songs]]\nname = \"Glory Days\"\n\n[[albums]]\nname = \"Born in the USA\"\n"
1630 testgenInvalid(t, input)
1631 }
1632
1633 func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose1(t *testing.T) {
1634 input := "[[albums]\nname = \"Born to Run\"\n"
1635 testgenInvalid(t, input)
1636 }
1637
1638 func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose2(t *testing.T) {
1639 input := "[[closing-bracket.missing]\nblaa=2\n"
1640 testgenInvalid(t, input)
1641 }
1642
1643 func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyDottedArray(t *testing.T) {
1644 input := "[fruit]\napple.color = \"red\"\n\n[[fruit.apple]]\n"
1645 testgenInvalid(t, input)
1646 }
1647
1648 func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyDottedTable(t *testing.T) {
1649 input := "[fruit]\napple.color = \"red\"\n\n[fruit.apple] # INVALID\n"
1650 testgenInvalid(t, input)
1651 }
1652
1653 func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyDottedTable2(t *testing.T) {
1654 input := "[fruit]\napple.taste.sweet = true\n\n[fruit.apple.taste] # INVALID\n"
1655 testgenInvalid(t, input)
1656 }
1657
1658 func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyTable(t *testing.T) {
1659 input := "[fruit]\ntype = \"apple\"\n\n[fruit.type]\napple = \"yes\"\n"
1660 testgenInvalid(t, input)
1661 }
1662
1663 func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateTableArray(t *testing.T) {
1664 input := "[tbl]\n[[tbl]]\n"
1665 testgenInvalid(t, input)
1666 }
1667
1668 func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateTableArray2(t *testing.T) {
1669 input := "[[tbl]]\n[tbl]\n"
1670 testgenInvalid(t, input)
1671 }
1672
1673 func TestTOMLTest_Invalid_Tests_Invalid_Table_Duplicate(t *testing.T) {
1674 input := "[a]\nb = 1\n\n[a]\nc = 2\n"
1675 testgenInvalid(t, input)
1676 }
1677
1678 func TestTOMLTest_Invalid_Tests_Invalid_Table_EmptyImplicitTable(t *testing.T) {
1679 input := "[naughty..naughty]\n"
1680 testgenInvalid(t, input)
1681 }
1682
1683 func TestTOMLTest_Invalid_Tests_Invalid_Table_Empty(t *testing.T) {
1684 input := "[]\n"
1685 testgenInvalid(t, input)
1686 }
1687
1688 func TestTOMLTest_Invalid_Tests_Invalid_Table_EqualsSign(t *testing.T) {
1689 input := "[name=bad]\n"
1690 testgenInvalid(t, input)
1691 }
1692
1693 func TestTOMLTest_Invalid_Tests_Invalid_Table_Llbrace(t *testing.T) {
1694 input := "[ [table]]\n"
1695 testgenInvalid(t, input)
1696 }
1697
1698 func TestTOMLTest_Invalid_Tests_Invalid_Table_NestedBracketsClose(t *testing.T) {
1699 input := "[a]b]\nzyx = 42\n"
1700 testgenInvalid(t, input)
1701 }
1702
1703 func TestTOMLTest_Invalid_Tests_Invalid_Table_NestedBracketsOpen(t *testing.T) {
1704 input := "[a[b]\nzyx = 42\n"
1705 testgenInvalid(t, input)
1706 }
1707
1708 func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose1(t *testing.T) {
1709 input := "[where will it end\nname = value\n\n"
1710 testgenInvalid(t, input)
1711 }
1712
1713 func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose2(t *testing.T) {
1714 input := "[closing-bracket.missingö\nblaa=2\n"
1715 testgenInvalid(t, input)
1716 }
1717
1718 func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose3(t *testing.T) {
1719 input := "[\"where will it end]\nname = value\n\n"
1720 testgenInvalid(t, input)
1721 }
1722
1723 func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose4(t *testing.T) {
1724 input := "[\n"
1725 testgenInvalid(t, input)
1726 }
1727
1728 func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose5(t *testing.T) {
1729 input := "[fwfw.wafw\n"
1730 testgenInvalid(t, input)
1731 }
1732
1733 func TestTOMLTest_Invalid_Tests_Invalid_Table_OverwriteArrayInParent(t *testing.T) {
1734 input := "[[parent-table.arr]]\n[parent-table]\nnot-arr = 1\narr = 2\n"
1735 testgenInvalid(t, input)
1736 }
1737
1738 func TestTOMLTest_Invalid_Tests_Invalid_Table_OverwriteBoolWithArray(t *testing.T) {
1739 input := "a=true\n[[a]]\n"
1740 testgenInvalid(t, input)
1741 }
1742
1743 func TestTOMLTest_Invalid_Tests_Invalid_Table_OverwriteWithDeepTable(t *testing.T) {
1744 input := "a=1\n[a.b.c.d]\n"
1745 testgenInvalid(t, input)
1746 }
1747
1748 func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine1(t *testing.T) {
1749 input := "# Define b as int, and try to use it as a table: error\n[a]\nb = 1\n\n[a.b]\nc = 2\n"
1750 testgenInvalid(t, input)
1751 }
1752
1753 func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine2(t *testing.T) {
1754 input := "[t1]\nt2.t3.v = 0\n[t1.t2]\n"
1755 testgenInvalid(t, input)
1756 }
1757
1758 func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine3(t *testing.T) {
1759 input := "[t1]\nt2.t3.v = 0\n[t1.t2.t3]\n"
1760 testgenInvalid(t, input)
1761 }
1762
1763 func TestTOMLTest_Invalid_Tests_Invalid_Table_Rrbrace(t *testing.T) {
1764 input := "[[table] ]\n"
1765 testgenInvalid(t, input)
1766 }
1767
1768 func TestTOMLTest_Invalid_Tests_Invalid_Table_TextAfterTable(t *testing.T) {
1769 input := "[error] this shouldn't be here\n"
1770 testgenInvalid(t, input)
1771 }
1772
1773 func TestTOMLTest_Invalid_Tests_Invalid_Table_Whitespace(t *testing.T) {
1774 input := "[invalid key]\n"
1775 testgenInvalid(t, input)
1776 }
1777
1778 func TestTOMLTest_Invalid_Tests_Invalid_Table_WithPound(t *testing.T) {
1779 input := "[key#group]\nanswer = 42\n"
1780 testgenInvalid(t, input)
1781 }
1782
1783 func TestTOMLTest_Valid_Array_ArraySubtables(t *testing.T) {
1784 input := "[[arr]]\n[arr.subtab]\nval=1\n\n[[arr]]\n[arr.subtab]\nval=2\n"
1785 jsonRef := "{\n \"arr\": [\n {\n \"subtab\": {\n \"val\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n {\n \"subtab\": {\n \"val\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n }\n ]\n}\n"
1786 testgenValid(t, input, jsonRef)
1787 }
1788
1789 func TestTOMLTest_Valid_Array_Array(t *testing.T) {
1790 input := "ints = [1, 2, 3, ]\nfloats = [1.1, 2.1, 3.1]\nstrings = [\"a\", \"b\", \"c\"]\ndates = [\n 1987-07-05T17:45:00Z,\n 1979-05-27T07:32:00Z,\n 2006-06-01T11:00:00Z,\n]\ncomments = [\n 1,\n 2, #this is ok\n]\n"
1791 jsonRef := "{\n \"comments\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n ],\n \"dates\": [\n {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:00Z\"\n },\n {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T07:32:00Z\"\n },\n {\n \"type\": \"datetime\",\n \"value\": \"2006-06-01T11:00:00Z\"\n }\n ],\n \"floats\": [\n {\n \"type\": \"float\",\n \"value\": \"1.1\"\n },\n {\n \"type\": \"float\",\n \"value\": \"2.1\"\n },\n {\n \"type\": \"float\",\n \"value\": \"3.1\"\n }\n ],\n \"ints\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n ],\n \"strings\": [\n {\n \"type\": \"string\",\n \"value\": \"a\"\n },\n {\n \"type\": \"string\",\n \"value\": \"b\"\n },\n {\n \"type\": \"string\",\n \"value\": \"c\"\n }\n ]\n}\n"
1792 testgenValid(t, input, jsonRef)
1793 }
1794
1795 func TestTOMLTest_Valid_Array_Bool(t *testing.T) {
1796 input := "a = [true, false]\n"
1797 jsonRef := "{\n \"a\": [\n {\n \"type\": \"bool\",\n \"value\": \"true\"\n },\n {\n \"type\": \"bool\",\n \"value\": \"false\"\n }\n ]\n}\n"
1798 testgenValid(t, input, jsonRef)
1799 }
1800
1801 func TestTOMLTest_Valid_Array_Empty(t *testing.T) {
1802 input := "thevoid = [[[[[]]]]]\n"
1803 jsonRef := "{\n \"thevoid\": [\n [\n [\n [\n []\n ]\n ]\n ]\n ]\n}\n"
1804 testgenValid(t, input, jsonRef)
1805 }
1806
1807 func TestTOMLTest_Valid_Array_Hetergeneous(t *testing.T) {
1808 input := "mixed = [[1, 2], [\"a\", \"b\"], [1.1, 2.1]]\n"
1809 jsonRef := "{\n \"mixed\": [\n [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n ],\n [\n {\n \"type\": \"string\",\n \"value\": \"a\"\n },\n {\n \"type\": \"string\",\n \"value\": \"b\"\n }\n ],\n [\n {\n \"type\": \"float\",\n \"value\": \"1.1\"\n },\n {\n \"type\": \"float\",\n \"value\": \"2.1\"\n }\n ]\n ]\n}\n"
1810 testgenValid(t, input, jsonRef)
1811 }
1812
1813 func TestTOMLTest_Valid_Array_MixedIntArray(t *testing.T) {
1814 input := "arrays-and-ints = [1, [\"Arrays are not integers.\"]]\n"
1815 jsonRef := "{\n \"arrays-and-ints\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n [\n {\n \"type\": \"string\",\n \"value\": \"Arrays are not integers.\"\n }\n ]\n ]\n}\n"
1816 testgenValid(t, input, jsonRef)
1817 }
1818
1819 func TestTOMLTest_Valid_Array_MixedIntFloat(t *testing.T) {
1820 input := "ints-and-floats = [1, 1.1]\n"
1821 jsonRef := "{\n \"ints-and-floats\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"float\",\n \"value\": \"1.1\"\n }\n ]\n}\n"
1822 testgenValid(t, input, jsonRef)
1823 }
1824
1825 func TestTOMLTest_Valid_Array_MixedIntString(t *testing.T) {
1826 input := "strings-and-ints = [\"hi\", 42]\n"
1827 jsonRef := "{\n \"strings-and-ints\": [\n {\n \"type\": \"string\",\n \"value\": \"hi\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n ]\n}\n"
1828 testgenValid(t, input, jsonRef)
1829 }
1830
1831 func TestTOMLTest_Valid_Array_MixedStringTable(t *testing.T) {
1832 input := "contributors = [\n \"Foo Bar <foo@example.com>\",\n { name = \"Baz Qux\", email = \"bazqux@example.com\", url = \"https://example.com/bazqux\" }\n]\n\n# Start with a table as the first element. This tests a case that some libraries\n# might have where they will check if the first entry is a table/map/hash/assoc\n# array and then encode it as a table array. This was a reasonable thing to do\n# before TOML 1.0 since arrays could only contain one type, but now it's no\n# longer.\nmixed = [{k=\"a\"}, \"b\", 1]\n"
1833 jsonRef := "{\n \"contributors\": [\n {\n \"type\": \"string\",\n \"value\": \"Foo Bar \\u003cfoo@example.com\\u003e\"\n },\n {\n \"email\": {\n \"type\": \"string\",\n \"value\": \"bazqux@example.com\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Baz Qux\"\n },\n \"url\": {\n \"type\": \"string\",\n \"value\": \"https://example.com/bazqux\"\n }\n }\n ],\n \"mixed\": [\n {\n \"k\": {\n \"type\": \"string\",\n \"value\": \"a\"\n }\n },\n {\n \"type\": \"string\",\n \"value\": \"b\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n ]\n}\n"
1834 testgenValid(t, input, jsonRef)
1835 }
1836
1837 func TestTOMLTest_Valid_Array_NestedDouble(t *testing.T) {
1838 input := "nest = [\n\t[\n\t\t[\"a\"],\n\t\t[1, 2, [3]]\n\t]\n]\n"
1839 jsonRef := "{\n \"nest\": [\n [\n [\n {\n \"type\": \"string\",\n \"value\": \"a\"\n }\n ],\n [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n [\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n ]\n ]\n ]\n ]\n}\n"
1840 testgenValid(t, input, jsonRef)
1841 }
1842
1843 func TestTOMLTest_Valid_Array_NestedInlineTable(t *testing.T) {
1844 input := "a = [ { b = {} } ]\n"
1845 jsonRef := "{\n \"a\": [\n {\n \"b\": {}\n }\n ]\n}\n"
1846 testgenValid(t, input, jsonRef)
1847 }
1848
1849 func TestTOMLTest_Valid_Array_Nested(t *testing.T) {
1850 input := "nest = [[\"a\"], [\"b\"]]\n"
1851 jsonRef := "{\n \"nest\": [\n [\n {\n \"type\": \"string\",\n \"value\": \"a\"\n }\n ],\n [\n {\n \"type\": \"string\",\n \"value\": \"b\"\n }\n ]\n ]\n}\n"
1852 testgenValid(t, input, jsonRef)
1853 }
1854
1855 func TestTOMLTest_Valid_Array_Nospaces(t *testing.T) {
1856 input := "ints = [1,2,3]\n"
1857 jsonRef := "{\n \"ints\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n ]\n}\n"
1858 testgenValid(t, input, jsonRef)
1859 }
1860
1861 func TestTOMLTest_Valid_Array_OpenParentTable(t *testing.T) {
1862 input := "[[parent-table.arr]]\n[[parent-table.arr]]\n[parent-table]\nnot-arr = 1\n"
1863 jsonRef := "{\n \"parent-table\": {\n \"arr\": [\n {},\n {}\n ],\n \"not-arr\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n}\n"
1864 testgenValid(t, input, jsonRef)
1865 }
1866
1867 func TestTOMLTest_Valid_Array_StringQuoteComma2(t *testing.T) {
1868 input := "title = [ \" \\\", \",]\n"
1869 jsonRef := "{\n \"title\": [\n {\n \"type\": \"string\",\n \"value\": \" \\\", \"\n }\n ]\n}\n"
1870 testgenValid(t, input, jsonRef)
1871 }
1872
1873 func TestTOMLTest_Valid_Array_StringQuoteComma(t *testing.T) {
1874 input := "title = [\n\"Client: \\\"XXXX\\\", Job: XXXX\",\n\"Code: XXXX\"\n]\n"
1875 jsonRef := "{\n \"title\": [\n {\n \"type\": \"string\",\n \"value\": \"Client: \\\"XXXX\\\", Job: XXXX\"\n },\n {\n \"type\": \"string\",\n \"value\": \"Code: XXXX\"\n }\n ]\n}\n"
1876 testgenValid(t, input, jsonRef)
1877 }
1878
1879 func TestTOMLTest_Valid_Array_StringWithComma2(t *testing.T) {
1880 input := "title = [\n\"\"\"Client: XXXX,\nJob: XXXX\"\"\",\n\"Code: XXXX\"\n]\n"
1881 jsonRef := "{\n \"title\": [\n {\n \"type\": \"string\",\n \"value\": \"Client: XXXX,\\nJob: XXXX\"\n },\n {\n \"type\": \"string\",\n \"value\": \"Code: XXXX\"\n }\n ]\n}\n"
1882 testgenValid(t, input, jsonRef)
1883 }
1884
1885 func TestTOMLTest_Valid_Array_StringWithComma(t *testing.T) {
1886 input := "title = [\n\"Client: XXXX, Job: XXXX\",\n\"Code: XXXX\"\n]\n"
1887 jsonRef := "{\n \"title\": [\n {\n \"type\": \"string\",\n \"value\": \"Client: XXXX, Job: XXXX\"\n },\n {\n \"type\": \"string\",\n \"value\": \"Code: XXXX\"\n }\n ]\n}\n"
1888 testgenValid(t, input, jsonRef)
1889 }
1890
1891 func TestTOMLTest_Valid_Array_Strings(t *testing.T) {
1892 input := "string_array = [ \"all\", 'strings', \"\"\"are the same\"\"\", '''type''']\n"
1893 jsonRef := "{\n \"string_array\": [\n {\n \"type\": \"string\",\n \"value\": \"all\"\n },\n {\n \"type\": \"string\",\n \"value\": \"strings\"\n },\n {\n \"type\": \"string\",\n \"value\": \"are the same\"\n },\n {\n \"type\": \"string\",\n \"value\": \"type\"\n }\n ]\n}\n"
1894 testgenValid(t, input, jsonRef)
1895 }
1896
1897 func TestTOMLTest_Valid_Array_TableArrayStringBackslash(t *testing.T) {
1898 input := "foo = [ { bar=\"\\\"{{baz}}\\\"\"} ]\n"
1899 jsonRef := "{\n \"foo\": [\n {\n \"bar\": {\n \"type\": \"string\",\n \"value\": \"\\\"{{baz}}\\\"\"\n }\n }\n ]\n}\n"
1900 testgenValid(t, input, jsonRef)
1901 }
1902
1903 func TestTOMLTest_Valid_Array_TrailingComma(t *testing.T) {
1904 input := "arr-1 = [1,]\n\narr-2 = [2,3,]\n\narr-3 = [4,\n]\n\narr-4 = [\n\t5,\n\t6,\n]\n"
1905 jsonRef := "{\n \"arr-1\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n ],\n \"arr-2\": [\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n ],\n \"arr-3\": [\n {\n \"type\": \"integer\",\n \"value\": \"4\"\n }\n ],\n \"arr-4\": [\n {\n \"type\": \"integer\",\n \"value\": \"5\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"6\"\n }\n ]\n}\n"
1906 testgenValid(t, input, jsonRef)
1907 }
1908
1909 func TestTOMLTest_Valid_Bool_Bool(t *testing.T) {
1910 input := "t = true\nf = false\n"
1911 jsonRef := "{\n \"f\": {\n \"type\": \"bool\",\n \"value\": \"false\"\n },\n \"t\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n}\n"
1912 testgenValid(t, input, jsonRef)
1913 }
1914
1915 func TestTOMLTest_Valid_Comment_AfterLiteralNoWs(t *testing.T) {
1916 input := "inf=inf#infinity\nnan=nan#not a number\ntrue=true#true\nfalse=false#false\n"
1917 jsonRef := "{\n \"false\": {\n \"type\": \"bool\",\n \"value\": \"false\"\n },\n \"inf\": {\n \"type\": \"float\",\n \"value\": \"inf\"\n },\n \"nan\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n },\n \"true\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n}\n"
1918 testgenValid(t, input, jsonRef)
1919 }
1920
1921 func TestTOMLTest_Valid_Comment_AtEof(t *testing.T) {
1922 input := "# This is a full-line comment\nkey = \"value\" # This is a comment at the end of a line\n"
1923 jsonRef := "{\n \"key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n }\n}\n"
1924 testgenValid(t, input, jsonRef)
1925 }
1926
1927 func TestTOMLTest_Valid_Comment_AtEof2(t *testing.T) {
1928 input := "# This is a full-line comment\nkey = \"value\" # This is a comment at the end of a line\n"
1929 jsonRef := "{\n \"key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n }\n}\n"
1930 testgenValid(t, input, jsonRef)
1931 }
1932
1933 func TestTOMLTest_Valid_Comment_Everywhere(t *testing.T) {
1934 input := "# Top comment.\n # Top comment.\n# Top comment.\n\n# [no-extraneous-groups-please]\n\n[group] # Comment\nanswer = 42 # Comment\n# no-extraneous-keys-please = 999\n# Inbetween comment.\nmore = [ # Comment\n # What about multiple # comments?\n # Can you handle it?\n #\n # Evil.\n# Evil.\n 42, 42, # Comments within arrays are fun.\n # What about multiple # comments?\n # Can you handle it?\n #\n # Evil.\n# Evil.\n# ] Did I fool you?\n] # Hopefully not.\n\n# Make sure the space between the datetime and \"#\" isn't lexed.\ndt = 1979-05-27T07:32:12-07:00 # c\nd = 1979-05-27 # Comment\n"
1935 jsonRef := "{\n \"group\": {\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n \"d\": {\n \"type\": \"date-local\",\n \"value\": \"1979-05-27\"\n },\n \"dt\": {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T07:32:12-07:00\"\n },\n \"more\": [\n {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n ]\n }\n}\n"
1936 testgenValid(t, input, jsonRef)
1937 }
1938
1939 func TestTOMLTest_Valid_Comment_Noeol(t *testing.T) {
1940 input := "# single comment without any eol characters"
1941 jsonRef := "{}\n"
1942 testgenValid(t, input, jsonRef)
1943 }
1944
1945 func TestTOMLTest_Valid_Comment_Nonascii(t *testing.T) {
1946 input := "# ~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\n"
1947 jsonRef := "{}\n"
1948 testgenValid(t, input, jsonRef)
1949 }
1950
1951 func TestTOMLTest_Valid_Comment_Tricky(t *testing.T) {
1952 input := "[section]#attached comment\n#[notsection]\none = \"11\"#cmt\ntwo = \"22#\"\nthree = '#'\n\nfour = \"\"\"# no comment\n# nor this\n#also not comment\"\"\"#is_comment\n\nfive = 5.5#66\nsix = 6#7\n8 = \"eight\"\n#nine = 99\nten = 10e2#1\neleven = 1.11e1#23\n\n[\"hash#tag\"]\n\"#!\" = \"hash bang\"\narr3 = [ \"#\", '#', \"\"\"###\"\"\" ]\narr4 = [ 1,# 9, 9,\n2#,9\n,#9\n3#]\n,4]\narr5 = [[[[#[\"#\"],\n[\"#\"]]]]#]\n]\ntbl1 = { \"#\" = '}#'}#}}\n\n\n"
1953 jsonRef := "{\n \"hash#tag\": {\n \"#!\": {\n \"type\": \"string\",\n \"value\": \"hash bang\"\n },\n \"arr3\": [\n {\n \"type\": \"string\",\n \"value\": \"#\"\n },\n {\n \"type\": \"string\",\n \"value\": \"#\"\n },\n {\n \"type\": \"string\",\n \"value\": \"###\"\n }\n ],\n \"arr4\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"4\"\n }\n ],\n \"arr5\": [\n [\n [\n [\n [\n {\n \"type\": \"string\",\n \"value\": \"#\"\n }\n ]\n ]\n ]\n ]\n ],\n \"tbl1\": {\n \"#\": {\n \"type\": \"string\",\n \"value\": \"}#\"\n }\n }\n },\n \"section\": {\n \"8\": {\n \"type\": \"string\",\n \"value\": \"eight\"\n },\n \"eleven\": {\n \"type\": \"float\",\n \"value\": \"11.1\"\n },\n \"five\": {\n \"type\": \"float\",\n \"value\": \"5.5\"\n },\n \"four\": {\n \"type\": \"string\",\n \"value\": \"# no comment\\n# nor this\\n#also not comment\"\n },\n \"one\": {\n \"type\": \"string\",\n \"value\": \"11\"\n },\n \"six\": {\n \"type\": \"integer\",\n \"value\": \"6\"\n },\n \"ten\": {\n \"type\": \"float\",\n \"value\": \"1000.0\"\n },\n \"three\": {\n \"type\": \"string\",\n \"value\": \"#\"\n },\n \"two\": {\n \"type\": \"string\",\n \"value\": \"22#\"\n }\n }\n}\n"
1954 testgenValid(t, input, jsonRef)
1955 }
1956
1957 func TestTOMLTest_Valid_Datetime_Datetime(t *testing.T) {
1958 input := "space = 1987-07-05 17:45:00Z\nlower = 1987-07-05t17:45:00z\n"
1959 jsonRef := "{\n \"lower\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:00Z\"\n },\n \"space\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:00Z\"\n }\n}\n"
1960 testgenValid(t, input, jsonRef)
1961 }
1962
1963 func TestTOMLTest_Valid_Datetime_Edge(t *testing.T) {
1964 input := "first-offset = 0001-01-01 00:00:00Z\nfirst-local = 0001-01-01 00:00:00\nfirst-date = 0001-01-01\n\nlast-offset = 9999-12-31 23:59:59Z\nlast-local = 9999-12-31 23:59:59\nlast-date = 9999-12-31\n"
1965 jsonRef := "{\n \"first-date\": {\n \"type\": \"date-local\",\n \"value\": \"0001-01-01\"\n },\n \"first-local\": {\n \"type\": \"datetime-local\",\n \"value\": \"0001-01-01T00:00:00\"\n },\n \"first-offset\": {\n \"type\": \"datetime\",\n \"value\": \"0001-01-01T00:00:00Z\"\n },\n \"last-date\": {\n \"type\": \"date-local\",\n \"value\": \"9999-12-31\"\n },\n \"last-local\": {\n \"type\": \"datetime-local\",\n \"value\": \"9999-12-31T23:59:59\"\n },\n \"last-offset\": {\n \"type\": \"datetime\",\n \"value\": \"9999-12-31T23:59:59Z\"\n }\n}\n"
1966 testgenValid(t, input, jsonRef)
1967 }
1968
1969 func TestTOMLTest_Valid_Datetime_LeapYear(t *testing.T) {
1970 input := "2000-datetime = 2000-02-29 15:15:15Z\n2000-datetime-local = 2000-02-29 15:15:15\n2000-date = 2000-02-29\n\n2024-datetime = 2024-02-29 15:15:15Z\n2024-datetime-local = 2024-02-29 15:15:15\n2024-date = 2024-02-29\n"
1971 jsonRef := "{\n \"2000-date\": {\n \"type\": \"date-local\",\n \"value\": \"2000-02-29\"\n },\n \"2000-datetime\": {\n \"type\": \"datetime\",\n \"value\": \"2000-02-29T15:15:15Z\"\n },\n \"2000-datetime-local\": {\n \"type\": \"datetime-local\",\n \"value\": \"2000-02-29T15:15:15\"\n },\n \"2024-date\": {\n \"type\": \"date-local\",\n \"value\": \"2024-02-29\"\n },\n \"2024-datetime\": {\n \"type\": \"datetime\",\n \"value\": \"2024-02-29T15:15:15Z\"\n },\n \"2024-datetime-local\": {\n \"type\": \"datetime-local\",\n \"value\": \"2024-02-29T15:15:15\"\n }\n}\n"
1972 testgenValid(t, input, jsonRef)
1973 }
1974
1975 func TestTOMLTest_Valid_Datetime_LocalDate(t *testing.T) {
1976 input := "bestdayever = 1987-07-05\n"
1977 jsonRef := "{\n \"bestdayever\": {\n \"type\": \"date-local\",\n \"value\": \"1987-07-05\"\n }\n}\n"
1978 testgenValid(t, input, jsonRef)
1979 }
1980
1981 func TestTOMLTest_Valid_Datetime_LocalTime(t *testing.T) {
1982 input := "besttimeever = 17:45:00\nmilliseconds = 10:32:00.555\n"
1983 jsonRef := "{\n \"besttimeever\": {\n \"type\": \"time-local\",\n \"value\": \"17:45:00\"\n },\n \"milliseconds\": {\n \"type\": \"time-local\",\n \"value\": \"10:32:00.555\"\n }\n}\n"
1984 testgenValid(t, input, jsonRef)
1985 }
1986
1987 func TestTOMLTest_Valid_Datetime_Local(t *testing.T) {
1988 input := "local = 1987-07-05T17:45:00\nmilli = 1977-12-21T10:32:00.555\nspace = 1987-07-05 17:45:00\n"
1989 jsonRef := "{\n \"local\": {\n \"type\": \"datetime-local\",\n \"value\": \"1987-07-05T17:45:00\"\n },\n \"milli\": {\n \"type\": \"datetime-local\",\n \"value\": \"1977-12-21T10:32:00.555\"\n },\n \"space\": {\n \"type\": \"datetime-local\",\n \"value\": \"1987-07-05T17:45:00\"\n }\n}\n"
1990 testgenValid(t, input, jsonRef)
1991 }
1992
1993 func TestTOMLTest_Valid_Datetime_Milliseconds(t *testing.T) {
1994 input := "utc1 = 1987-07-05T17:45:56.123Z\nutc2 = 1987-07-05T17:45:56.6Z\nwita1 = 1987-07-05T17:45:56.123+08:00\nwita2 = 1987-07-05T17:45:56.6+08:00\n"
1995 jsonRef := "{\n \"utc1\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.123Z\"\n },\n \"utc2\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.600Z\"\n },\n \"wita1\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.123+08:00\"\n },\n \"wita2\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.600+08:00\"\n }\n}\n"
1996 testgenValid(t, input, jsonRef)
1997 }
1998
1999 func TestTOMLTest_Valid_Datetime_Timezone(t *testing.T) {
2000 input := "utc = 1987-07-05T17:45:56Z\npdt = 1987-07-05T17:45:56-05:00\nnzst = 1987-07-05T17:45:56+12:00\nnzdt = 1987-07-05T17:45:56+13:00 # DST\n"
2001 jsonRef := "{\n \"nzdt\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56+13:00\"\n },\n \"nzst\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56+12:00\"\n },\n \"pdt\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56-05:00\"\n },\n \"utc\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56Z\"\n }\n}\n"
2002 testgenValid(t, input, jsonRef)
2003 }
2004
2005 func TestTOMLTest_Valid_Float_Exponent(t *testing.T) {
2006 input := "lower = 3e2\nupper = 3E2\nneg = 3e-2\npos = 3E+2\nzero = 3e0\npointlower = 3.1e2\npointupper = 3.1E2\nminustenth = -1E-1\n"
2007 jsonRef := "{\n \"lower\": {\n \"type\": \"float\",\n \"value\": \"300.0\"\n },\n \"minustenth\": {\n \"type\": \"float\",\n \"value\": \"-0.1\"\n },\n \"neg\": {\n \"type\": \"float\",\n \"value\": \"0.03\"\n },\n \"pointlower\": {\n \"type\": \"float\",\n \"value\": \"310.0\"\n },\n \"pointupper\": {\n \"type\": \"float\",\n \"value\": \"310.0\"\n },\n \"pos\": {\n \"type\": \"float\",\n \"value\": \"300.0\"\n },\n \"upper\": {\n \"type\": \"float\",\n \"value\": \"300.0\"\n },\n \"zero\": {\n \"type\": \"float\",\n \"value\": \"3.0\"\n }\n}\n"
2008 testgenValid(t, input, jsonRef)
2009 }
2010
2011 func TestTOMLTest_Valid_Float_Float(t *testing.T) {
2012 input := "pi = 3.14\npospi = +3.14\nnegpi = -3.14\nzero-intpart = 0.123\n"
2013 jsonRef := "{\n \"negpi\": {\n \"type\": \"float\",\n \"value\": \"-3.14\"\n },\n \"pi\": {\n \"type\": \"float\",\n \"value\": \"3.14\"\n },\n \"pospi\": {\n \"type\": \"float\",\n \"value\": \"3.14\"\n },\n \"zero-intpart\": {\n \"type\": \"float\",\n \"value\": \"0.123\"\n }\n}\n"
2014 testgenValid(t, input, jsonRef)
2015 }
2016
2017 func TestTOMLTest_Valid_Float_InfAndNan(t *testing.T) {
2018 input := "# We don't encode +nan and -nan back with the signs; many languages don't\n# support a sign on NaN (it doesn't really make much sense).\nnan = nan\nnan_neg = -nan\nnan_plus = +nan\ninfinity = inf\ninfinity_neg = -inf\ninfinity_plus = +inf\n"
2019 jsonRef := "{\n \"infinity\": {\n \"type\": \"float\",\n \"value\": \"inf\"\n },\n \"infinity_neg\": {\n \"type\": \"float\",\n \"value\": \"-inf\"\n },\n \"infinity_plus\": {\n \"type\": \"float\",\n \"value\": \"+inf\"\n },\n \"nan\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n },\n \"nan_neg\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n },\n \"nan_plus\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n }\n}\n"
2020 testgenValid(t, input, jsonRef)
2021 }
2022
2023 func TestTOMLTest_Valid_Float_Long(t *testing.T) {
2024 input := "longpi = 3.141592653589793\nneglongpi = -3.141592653589793\n"
2025 jsonRef := "{\n \"longpi\": {\n \"type\": \"float\",\n \"value\": \"3.141592653589793\"\n },\n \"neglongpi\": {\n \"type\": \"float\",\n \"value\": \"-3.141592653589793\"\n }\n}\n"
2026 testgenValid(t, input, jsonRef)
2027 }
2028
2029 func TestTOMLTest_Valid_Float_Underscore(t *testing.T) {
2030 input := "before = 3_141.5927\nafter = 3141.592_7\nexponent = 3e1_4\n"
2031 jsonRef := "{\n \"after\": {\n \"type\": \"float\",\n \"value\": \"3141.5927\"\n },\n \"before\": {\n \"type\": \"float\",\n \"value\": \"3141.5927\"\n },\n \"exponent\": {\n \"type\": \"float\",\n \"value\": \"3.0e14\"\n }\n}\n"
2032 testgenValid(t, input, jsonRef)
2033 }
2034
2035 func TestTOMLTest_Valid_Float_Zero(t *testing.T) {
2036 input := "zero = 0.0\nsigned-pos = +0.0\nsigned-neg = -0.0\nexponent = 0e0\nexponent-two-0 = 0e00\nexponent-signed-pos = +0e0\nexponent-signed-neg = -0e0\n"
2037 jsonRef := "{\n \"exponent\": {\n \"type\": \"float\",\n \"value\": \"0\"\n },\n \"exponent-signed-neg\": {\n \"type\": \"float\",\n \"value\": \"-0\"\n },\n \"exponent-signed-pos\": {\n \"type\": \"float\",\n \"value\": \"0\"\n },\n \"exponent-two-0\": {\n \"type\": \"float\",\n \"value\": \"0\"\n },\n \"signed-neg\": {\n \"type\": \"float\",\n \"value\": \"-0\"\n },\n \"signed-pos\": {\n \"type\": \"float\",\n \"value\": \"0\"\n },\n \"zero\": {\n \"type\": \"float\",\n \"value\": \"0\"\n }\n}\n"
2038 testgenValid(t, input, jsonRef)
2039 }
2040
2041 func TestTOMLTest_Valid_InlineTable_Array(t *testing.T) {
2042 input := "people = [{first_name = \"Bruce\", last_name = \"Springsteen\"},\n {first_name = \"Eric\", last_name = \"Clapton\"},\n {first_name = \"Bob\", last_name = \"Seger\"}]\n"
2043 jsonRef := "{\n \"people\": [\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Bruce\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Springsteen\"\n }\n },\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Eric\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Clapton\"\n }\n },\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Bob\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Seger\"\n }\n }\n ]\n}\n"
2044 testgenValid(t, input, jsonRef)
2045 }
2046
2047 func TestTOMLTest_Valid_InlineTable_Bool(t *testing.T) {
2048 input := "a = {a = true, b = false}\n"
2049 jsonRef := "{\n \"a\": {\n \"a\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n },\n \"b\": {\n \"type\": \"bool\",\n \"value\": \"false\"\n }\n }\n}\n"
2050 testgenValid(t, input, jsonRef)
2051 }
2052
2053 func TestTOMLTest_Valid_InlineTable_Empty(t *testing.T) {
2054 input := "empty1 = {}\nempty2 = { }\nempty_in_array = [ { not_empty = 1 }, {} ]\nempty_in_array2 = [{},{not_empty=1}]\nmany_empty = [{},{},{}]\nnested_empty = {\"empty\"={}}\nwith_cmt ={ }#nothing here\n"
2055 jsonRef := "{\n \"empty1\": {},\n \"empty2\": {},\n \"empty_in_array\": [\n {\n \"not_empty\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n {}\n ],\n \"empty_in_array2\": [\n {},\n {\n \"not_empty\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n ],\n \"many_empty\": [\n {},\n {},\n {}\n ],\n \"nested_empty\": {\n \"empty\": {}\n },\n \"with_cmt\": {}\n}\n"
2056 testgenValid(t, input, jsonRef)
2057 }
2058
2059 func TestTOMLTest_Valid_InlineTable_EndInBool(t *testing.T) {
2060 input := "black = { python=\">3.6\", version=\">=18.9b0\", allow_prereleases=true }\n"
2061 jsonRef := "{\n \"black\": {\n \"allow_prereleases\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n },\n \"python\": {\n \"type\": \"string\",\n \"value\": \"\\u003e3.6\"\n },\n \"version\": {\n \"type\": \"string\",\n \"value\": \"\\u003e=18.9b0\"\n }\n }\n}\n"
2062 testgenValid(t, input, jsonRef)
2063 }
2064
2065 func TestTOMLTest_Valid_InlineTable_InlineTable(t *testing.T) {
2066 input := "name = { first = \"Tom\", last = \"Preston-Werner\" }\npoint = { x = 1, y = 2 }\nsimple = { a = 1 }\nstr-key = { \"a\" = 1 }\ntable-array = [{ \"a\" = 1 }, { \"b\" = 2 }]\n"
2067 jsonRef := "{\n \"name\": {\n \"first\": {\n \"type\": \"string\",\n \"value\": \"Tom\"\n },\n \"last\": {\n \"type\": \"string\",\n \"value\": \"Preston-Werner\"\n }\n },\n \"point\": {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n },\n \"simple\": {\n \"a\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n \"str-key\": {\n \"a\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n \"table-array\": [\n {\n \"a\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n ]\n}\n"
2068 testgenValid(t, input, jsonRef)
2069 }
2070
2071 func TestTOMLTest_Valid_InlineTable_KeyDotted(t *testing.T) {
2072 input := "inline = {a.b = 42}\n\nmany.dots.here.dot.dot.dot = {a.b.c = 1, a.b.d = 2}\n\na = { a.b = 1 }\nb = { \"a\".\"b\" = 1 }\nc = { a . b = 1 }\nd = { 'a' . \"b\" = 1 }\ne = {a.b=1}\n\n[tbl]\na.b.c = {d.e=1}\n\n[tbl.x]\na.b.c = {d.e=1}\n\n[[arr]]\nt = {a.b=1}\nT = {a.b=1}\n\n[[arr]]\nt = {a.b=2}\nT = {a.b=2}\n"
2073 jsonRef := "{\n \"a\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n \"arr\": [\n {\n \"T\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n \"t\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n }\n },\n {\n \"T\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n },\n \"t\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n }\n }\n ],\n \"b\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n \"c\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n \"d\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n \"e\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n },\n \"inline\": {\n \"a\": {\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n }\n },\n \"many\": {\n \"dots\": {\n \"here\": {\n \"dot\": {\n \"dot\": {\n \"dot\": {\n \"a\": {\n \"b\": {\n \"c\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"d\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n }\n }\n }\n }\n }\n }\n },\n \"tbl\": {\n \"a\": {\n \"b\": {\n \"c\": {\n \"d\": {\n \"e\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n }\n }\n },\n \"x\": {\n \"a\": {\n \"b\": {\n \"c\": {\n \"d\": {\n \"e\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n }\n }\n }\n }\n }\n}\n"
2074 testgenValid(t, input, jsonRef)
2075 }
2076
2077 func TestTOMLTest_Valid_InlineTable_Multiline(t *testing.T) {
2078 input := "tbl_multiline = { a = 1, b = \"\"\"\nmultiline\n\"\"\", c = \"\"\"and yet\nanother line\"\"\", d = 4 }\n"
2079 jsonRef := "{\n \"tbl_multiline\": {\n \"a\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"b\": {\n \"type\": \"string\",\n \"value\": \"multiline\\n\"\n },\n \"c\": {\n \"type\": \"string\",\n \"value\": \"and yet\\nanother line\"\n },\n \"d\": {\n \"type\": \"integer\",\n \"value\": \"4\"\n }\n }\n}\n"
2080 testgenValid(t, input, jsonRef)
2081 }
2082
2083 func TestTOMLTest_Valid_InlineTable_Nest(t *testing.T) {
2084 input := "tbl_tbl_empty = { tbl_0 = {} }\ntbl_tbl_val = { tbl_1 = { one = 1 } }\ntbl_arr_tbl = { arr_tbl = [ { one = 1 } ] }\narr_tbl_tbl = [ { tbl = { one = 1 } } ]\n\n# Array-of-array-of-table is interesting because it can only\n# be represented in inline form.\narr_arr_tbl_empty = [ [ {} ] ]\narr_arr_tbl_val = [ [ { one = 1 } ] ]\narr_arr_tbls = [ [ { one = 1 }, { two = 2 } ] ]\n"
2085 jsonRef := "{\n \"arr_arr_tbl_empty\": [\n [\n {}\n ]\n ],\n \"arr_arr_tbl_val\": [\n [\n {\n \"one\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n ]\n ],\n \"arr_arr_tbls\": [\n [\n {\n \"one\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n {\n \"two\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n ]\n ],\n \"arr_tbl_tbl\": [\n {\n \"tbl\": {\n \"one\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n }\n ],\n \"tbl_arr_tbl\": {\n \"arr_tbl\": [\n {\n \"one\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n ]\n },\n \"tbl_tbl_empty\": {\n \"tbl_0\": {}\n },\n \"tbl_tbl_val\": {\n \"tbl_1\": {\n \"one\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n }\n}\n"
2086 testgenValid(t, input, jsonRef)
2087 }
2088
2089 func TestTOMLTest_Valid_InlineTable_Spaces(t *testing.T) {
2090 input := "# https://github.com/toml-lang/toml-test/issues/146\nclap-1 = { version = \"4\" , features = [\"derive\", \"cargo\"] }\n\n# Contains some literal tabs!\nclap-2 = { version = \"4\"\t \t,\t \tfeatures = [ \"derive\" \t , \t \"cargo\" ] , nest = { \t \"a\" = 'x' , \t 'b' = [ 1.5 , 9.0 ] } }\n"
2091 jsonRef := "{\n \"clap-1\": {\n \"features\": [\n {\n \"type\": \"string\",\n \"value\": \"derive\"\n },\n {\n \"type\": \"string\",\n \"value\": \"cargo\"\n }\n ],\n \"version\": {\n \"type\": \"string\",\n \"value\": \"4\"\n }\n },\n \"clap-2\": {\n \"features\": [\n {\n \"type\": \"string\",\n \"value\": \"derive\"\n },\n {\n \"type\": \"string\",\n \"value\": \"cargo\"\n }\n ],\n \"nest\": {\n \"a\": {\n \"type\": \"string\",\n \"value\": \"x\"\n },\n \"b\": [\n {\n \"type\": \"float\",\n \"value\": \"1.5\"\n },\n {\n \"type\": \"float\",\n \"value\": \"9\"\n }\n ]\n },\n \"version\": {\n \"type\": \"string\",\n \"value\": \"4\"\n }\n }\n}\n"
2092 testgenValid(t, input, jsonRef)
2093 }
2094
2095 func TestTOMLTest_Valid_Integer_Integer(t *testing.T) {
2096 input := "answer = 42\nposanswer = +42\nneganswer = -42\nzero = 0\n"
2097 jsonRef := "{\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n \"neganswer\": {\n \"type\": \"integer\",\n \"value\": \"-42\"\n },\n \"posanswer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n \"zero\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n }\n}\n"
2098 testgenValid(t, input, jsonRef)
2099 }
2100
2101 func TestTOMLTest_Valid_Integer_Literals(t *testing.T) {
2102 input := "bin1 = 0b11010110\nbin2 = 0b1_0_1\n\noct1 = 0o01234567\noct2 = 0o755\noct3 = 0o7_6_5\n\nhex1 = 0xDEADBEEF\nhex2 = 0xdeadbeef\nhex3 = 0xdead_beef\nhex4 = 0x00987\n"
2103 jsonRef := "{\n \"bin1\": {\n \"type\": \"integer\",\n \"value\": \"214\"\n },\n \"bin2\": {\n \"type\": \"integer\",\n \"value\": \"5\"\n },\n \"hex1\": {\n \"type\": \"integer\",\n \"value\": \"3735928559\"\n },\n \"hex2\": {\n \"type\": \"integer\",\n \"value\": \"3735928559\"\n },\n \"hex3\": {\n \"type\": \"integer\",\n \"value\": \"3735928559\"\n },\n \"hex4\": {\n \"type\": \"integer\",\n \"value\": \"2439\"\n },\n \"oct1\": {\n \"type\": \"integer\",\n \"value\": \"342391\"\n },\n \"oct2\": {\n \"type\": \"integer\",\n \"value\": \"493\"\n },\n \"oct3\": {\n \"type\": \"integer\",\n \"value\": \"501\"\n }\n}\n"
2104 testgenValid(t, input, jsonRef)
2105 }
2106
2107 func TestTOMLTest_Valid_Integer_Long(t *testing.T) {
2108 input := "int64-max = 9223372036854775807\nint64-max-neg = -9223372036854775808\n"
2109 jsonRef := "{\n \"int64-max\": {\n \"type\": \"integer\",\n \"value\": \"9223372036854775807\"\n },\n \"int64-max-neg\": {\n \"type\": \"integer\",\n \"value\": \"-9223372036854775808\"\n }\n}\n"
2110 testgenValid(t, input, jsonRef)
2111 }
2112
2113 func TestTOMLTest_Valid_Integer_Underscore(t *testing.T) {
2114 input := "kilo = 1_000\nx = 1_1_1_1\n"
2115 jsonRef := "{\n \"kilo\": {\n \"type\": \"integer\",\n \"value\": \"1000\"\n },\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1111\"\n }\n}\n"
2116 testgenValid(t, input, jsonRef)
2117 }
2118
2119 func TestTOMLTest_Valid_Integer_Zero(t *testing.T) {
2120 input := "d1 = 0\nd2 = +0\nd3 = -0\n\nh1 = 0x0\nh2 = 0x00\nh3 = 0x00000\n\no1 = 0o0\na2 = 0o00\na3 = 0o00000\n\nb1 = 0b0\nb2 = 0b00\nb3 = 0b00000\n"
2121 jsonRef := "{\n \"a2\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"a3\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"b1\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"b2\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"b3\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"d1\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"d2\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"d3\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"h1\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"h2\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"h3\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"o1\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n }\n}\n"
2122 testgenValid(t, input, jsonRef)
2123 }
2124
2125 func TestTOMLTest_Valid_Key_Alphanum(t *testing.T) {
2126 input := "alpha = \"a\"\n123 = \"num\"\n000111 = \"leading\"\n10e3 = \"false float\"\none1two2 = \"mixed\"\nwith-dash = \"dashed\"\nunder_score = \"___\"\n34-11 = 23\n\n[2018_10]\n001 = 1\n\n[a-a-a]\n_ = false\n"
2127 jsonRef := "{\n \"000111\": {\n \"type\": \"string\",\n \"value\": \"leading\"\n },\n \"10e3\": {\n \"type\": \"string\",\n \"value\": \"false float\"\n },\n \"123\": {\n \"type\": \"string\",\n \"value\": \"num\"\n },\n \"2018_10\": {\n \"001\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n \"34-11\": {\n \"type\": \"integer\",\n \"value\": \"23\"\n },\n \"a-a-a\": {\n \"_\": {\n \"type\": \"bool\",\n \"value\": \"false\"\n }\n },\n \"alpha\": {\n \"type\": \"string\",\n \"value\": \"a\"\n },\n \"one1two2\": {\n \"type\": \"string\",\n \"value\": \"mixed\"\n },\n \"under_score\": {\n \"type\": \"string\",\n \"value\": \"___\"\n },\n \"with-dash\": {\n \"type\": \"string\",\n \"value\": \"dashed\"\n }\n}\n"
2128 testgenValid(t, input, jsonRef)
2129 }
2130
2131 func TestTOMLTest_Valid_Key_CaseSensitive(t *testing.T) {
2132 input := "sectioN = \"NN\"\n\n[section]\nname = \"lower\"\nNAME = \"upper\"\nName = \"capitalized\"\n\n[Section]\nname = \"different section!!\"\n\"μ\" = \"greek small letter mu\"\n\"Μ\" = \"greek capital letter MU\"\nM = \"latin letter M\"\n\n"
2133 jsonRef := "{\n \"Section\": {\n \"M\": {\n \"type\": \"string\",\n \"value\": \"latin letter M\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"different section!!\"\n },\n \"Μ\": {\n \"type\": \"string\",\n \"value\": \"greek capital letter MU\"\n },\n \"μ\": {\n \"type\": \"string\",\n \"value\": \"greek small letter mu\"\n }\n },\n \"sectioN\": {\n \"type\": \"string\",\n \"value\": \"NN\"\n },\n \"section\": {\n \"NAME\": {\n \"type\": \"string\",\n \"value\": \"upper\"\n },\n \"Name\": {\n \"type\": \"string\",\n \"value\": \"capitalized\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"lower\"\n }\n }\n}\n"
2134 testgenValid(t, input, jsonRef)
2135 }
2136
2137 func TestTOMLTest_Valid_Key_DottedEmpty(t *testing.T) {
2138 input := "''.x = \"empty.x\"\nx.\"\" = \"x.empty\"\n[a]\n\"\".'' = \"empty.empty\"\n"
2139 jsonRef := "{\n \"\": {\n \"x\": {\n \"type\": \"string\",\n \"value\": \"empty.x\"\n }\n },\n \"a\": {\n \"\": {\n \"\": {\n \"type\": \"string\",\n \"value\": \"empty.empty\"\n }\n }\n },\n \"x\": {\n \"\": {\n \"type\": \"string\",\n \"value\": \"x.empty\"\n }\n }\n}\n"
2140 testgenValid(t, input, jsonRef)
2141 }
2142
2143 func TestTOMLTest_Valid_Key_Dotted(t *testing.T) {
2144 input := "# Note: this file contains literal tab characters.\n\nname.first = \"Arthur\"\n\"name\".'last' = \"Dent\"\n\nmany.dots.here.dot.dot.dot = 42\n\n# Space are ignored, and key parts can be quoted.\ncount.a = 1\ncount . b = 2\n\"count\".\"c\" = 3\n\"count\" . \"d\" = 4\n'count'.'e' = 5\n'count' . 'f' = 6\n\"count\".'g' = 7\n\"count\" . 'h' = 8\ncount.'i' = 9\ncount \t.\t 'j'\t = 10\n\"count\".k = 11\n\"count\" . l = 12\n\n[tbl]\na.b.c = 42.666\n\n[a.few.dots]\npolka.dot = \"again?\"\npolka.dance-with = \"Dot\"\n\n[[arr]]\na.b.c=1\na.b.d=2\n\n[[arr]]\na.b.c=3\na.b.d=4\n"
2145 jsonRef := "{\n \"a\": {\n \"few\": {\n \"dots\": {\n \"polka\": {\n \"dance-with\": {\n \"type\": \"string\",\n \"value\": \"Dot\"\n },\n \"dot\": {\n \"type\": \"string\",\n \"value\": \"again?\"\n }\n }\n }\n }\n },\n \"arr\": [\n {\n \"a\": {\n \"b\": {\n \"c\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"d\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n }\n },\n {\n \"a\": {\n \"b\": {\n \"c\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n },\n \"d\": {\n \"type\": \"integer\",\n \"value\": \"4\"\n }\n }\n }\n }\n ],\n \"count\": {\n \"a\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"b\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n \"c\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n },\n \"d\": {\n \"type\": \"integer\",\n \"value\": \"4\"\n },\n \"e\": {\n \"type\": \"integer\",\n \"value\": \"5\"\n },\n \"f\": {\n \"type\": \"integer\",\n \"value\": \"6\"\n },\n \"g\": {\n \"type\": \"integer\",\n \"value\": \"7\"\n },\n \"h\": {\n \"type\": \"integer\",\n \"value\": \"8\"\n },\n \"i\": {\n \"type\": \"integer\",\n \"value\": \"9\"\n },\n \"j\": {\n \"type\": \"integer\",\n \"value\": \"10\"\n },\n \"k\": {\n \"type\": \"integer\",\n \"value\": \"11\"\n },\n \"l\": {\n \"type\": \"integer\",\n \"value\": \"12\"\n }\n },\n \"many\": {\n \"dots\": {\n \"here\": {\n \"dot\": {\n \"dot\": {\n \"dot\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n }\n }\n }\n }\n },\n \"name\": {\n \"first\": {\n \"type\": \"string\",\n \"value\": \"Arthur\"\n },\n \"last\": {\n \"type\": \"string\",\n \"value\": \"Dent\"\n }\n },\n \"tbl\": {\n \"a\": {\n \"b\": {\n \"c\": {\n \"type\": \"float\",\n \"value\": \"42.666\"\n }\n }\n }\n }\n}\n"
2146 testgenValid(t, input, jsonRef)
2147 }
2148
2149 func TestTOMLTest_Valid_Key_Empty1(t *testing.T) {
2150 input := "\"\" = \"blank\"\n"
2151 jsonRef := "{\n \"\": {\n \"type\": \"string\",\n \"value\": \"blank\"\n }\n}\n"
2152 testgenValid(t, input, jsonRef)
2153 }
2154
2155 func TestTOMLTest_Valid_Key_Empty2(t *testing.T) {
2156 input := "'' = \"blank\"\n"
2157 jsonRef := "{\n \"\": {\n \"type\": \"string\",\n \"value\": \"blank\"\n }\n}\n"
2158 testgenValid(t, input, jsonRef)
2159 }
2160
2161 func TestTOMLTest_Valid_Key_Empty3(t *testing.T) {
2162 input := "''=0\n"
2163 jsonRef := "{\n \"\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n }\n}\n"
2164 testgenValid(t, input, jsonRef)
2165 }
2166
2167 func TestTOMLTest_Valid_Key_EqualsNospace(t *testing.T) {
2168 input := "answer=42\n"
2169 jsonRef := "{\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n}\n"
2170 testgenValid(t, input, jsonRef)
2171 }
2172
2173 func TestTOMLTest_Valid_Key_Escapes(t *testing.T) {
2174 input := "\"\\n\" = \"newline\"\n\"\\b\" = \"bell\"\n\"\\u00c0\" = \"latin capital letter A with grave\"\n\"\\\"\" = \"just a quote\"\n\n[\"backsp\\b\\b\"]\n\n[\"\\\"quoted\\\"\"]\nquote = true\n\n[\"a.b\".\"\\u00c0\"]\n"
2175 jsonRef := "{\n \"\\u0008\": {\n \"type\": \"string\",\n \"value\": \"bell\"\n },\n \"\\n\": {\n \"type\": \"string\",\n \"value\": \"newline\"\n },\n \"\\\"\": {\n \"type\": \"string\",\n \"value\": \"just a quote\"\n },\n \"\\\"quoted\\\"\": {\n \"quote\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n },\n \"a.b\": {\n \"À\": {}\n },\n \"backsp\\u0008\\u0008\": {},\n \"À\": {\n \"type\": \"string\",\n \"value\": \"latin capital letter A with grave\"\n }\n}\n"
2176 testgenValid(t, input, jsonRef)
2177 }
2178
2179 func TestTOMLTest_Valid_Key_NumericDotted(t *testing.T) {
2180 input := "1.2 = 3\n"
2181 jsonRef := "{\n \"1\": {\n \"2\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n }\n}\n"
2182 testgenValid(t, input, jsonRef)
2183 }
2184
2185 func TestTOMLTest_Valid_Key_Numeric(t *testing.T) {
2186 input := "1 = 1\n"
2187 jsonRef := "{\n \"1\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n}\n"
2188 testgenValid(t, input, jsonRef)
2189 }
2190
2191 func TestTOMLTest_Valid_Key_QuotedDots(t *testing.T) {
2192 input := "plain = 1\n\"with.dot\" = 2\n\n[plain_table]\nplain = 3\n\"with.dot\" = 4\n\n[table.withdot]\nplain = 5\n\"key.with.dots\" = 6\n"
2193 jsonRef := "{\n \"plain\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"plain_table\": {\n \"plain\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n },\n \"with.dot\": {\n \"type\": \"integer\",\n \"value\": \"4\"\n }\n },\n \"table\": {\n \"withdot\": {\n \"key.with.dots\": {\n \"type\": \"integer\",\n \"value\": \"6\"\n },\n \"plain\": {\n \"type\": \"integer\",\n \"value\": \"5\"\n }\n }\n },\n \"with.dot\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n}\n"
2194 testgenValid(t, input, jsonRef)
2195 }
2196
2197 func TestTOMLTest_Valid_Key_QuotedUnicode(t *testing.T) {
2198 input := "\n\"\\u0000\" = \"null\"\n'\\u0000' = \"different key\"\n\"\\u0008 \\u000c \\U00000041 \\u007f \\u0080 \\u00ff \\ud7ff \\ue000 \\uffff \\U00010000 \\U0010ffff\" = \"escaped key\"\n\n\"~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\" = \"basic key\"\n'l ~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff' = \"literal key\"\n"
2199 jsonRef := "{\n \"\\u0000\": {\n \"type\": \"string\",\n \"value\": \"null\"\n },\n \"\\u0008 \\u000c A \x7f \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\": {\n \"type\": \"string\",\n \"value\": \"escaped key\"\n },\n \"\\\\u0000\": {\n \"type\": \"string\",\n \"value\": \"different key\"\n },\n \"l ~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\": {\n \"type\": \"string\",\n \"value\": \"literal key\"\n },\n \"~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\": {\n \"type\": \"string\",\n \"value\": \"basic key\"\n }\n}\n"
2200 testgenValid(t, input, jsonRef)
2201 }
2202
2203 func TestTOMLTest_Valid_Key_Space(t *testing.T) {
2204 input := "# Keep whitespace inside quotes keys at all positions.\n\"a b\" = 1\n\" c d \" = 2\n\n[ \" tbl \" ]\n\"\\ttab\\ttab\\t\" = \"tab\"\n"
2205 jsonRef := "{\n \" c d \": {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n \" tbl \": {\n \"\\ttab\\ttab\\t\": {\n \"type\": \"string\",\n \"value\": \"tab\"\n }\n },\n \"a b\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n}\n"
2206 testgenValid(t, input, jsonRef)
2207 }
2208
2209 func TestTOMLTest_Valid_Key_SpecialChars(t *testing.T) {
2210 input := "\"=~!@$^&*()_+-`1234567890[]|/?><.,;:'=\" = 1\n"
2211 jsonRef := "{\n \"=~!@$^\\u0026*()_+-`1234567890[]|/?\\u003e\\u003c.,;:'=\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n}\n"
2212 testgenValid(t, input, jsonRef)
2213 }
2214
2215 func TestTOMLTest_Valid_Key_SpecialWord(t *testing.T) {
2216 input := "false = false\ntrue = 1\ninf = 100000000\nnan = \"ceci n'est pas un nombre\"\n\n"
2217 jsonRef := "{\n \"false\": {\n \"type\": \"bool\",\n \"value\": \"false\"\n },\n \"inf\": {\n \"type\": \"integer\",\n \"value\": \"100000000\"\n },\n \"nan\": {\n \"type\": \"string\",\n \"value\": \"ceci n'est pas un nombre\"\n },\n \"true\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n}\n"
2218 testgenValid(t, input, jsonRef)
2219 }
2220
2221 func TestTOMLTest_Valid_Key_Zero(t *testing.T) {
2222 input := "0=0\n"
2223 jsonRef := "{\n \"0\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n }\n}\n"
2224 testgenValid(t, input, jsonRef)
2225 }
2226
2227 func TestTOMLTest_Valid_Spec_Array0(t *testing.T) {
2228 input := "integers = [ 1, 2, 3 ]\ncolors = [ \"red\", \"yellow\", \"green\" ]\nnested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ]\nnested_mixed_array = [ [ 1, 2 ], [\"a\", \"b\", \"c\"] ]\nstring_array = [ \"all\", 'strings', \"\"\"are the same\"\"\", '''type''' ]\n\n# Mixed-type arrays are allowed\nnumbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]\ncontributors = [\n \"Foo Bar <foo@example.com>\",\n { name = \"Baz Qux\", email = \"bazqux@example.com\", url = \"https://example.com/bazqux\" }\n]\n"
2229 jsonRef := "{\n \"colors\": [\n {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n {\n \"type\": \"string\",\n \"value\": \"yellow\"\n },\n {\n \"type\": \"string\",\n \"value\": \"green\"\n }\n ],\n \"contributors\": [\n {\n \"type\": \"string\",\n \"value\": \"Foo Bar \\u003cfoo@example.com\\u003e\"\n },\n {\n \"email\": {\n \"type\": \"string\",\n \"value\": \"bazqux@example.com\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Baz Qux\"\n },\n \"url\": {\n \"type\": \"string\",\n \"value\": \"https://example.com/bazqux\"\n }\n }\n ],\n \"integers\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n ],\n \"nested_arrays_of_ints\": [\n [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n ],\n [\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"4\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"5\"\n }\n ]\n ],\n \"nested_mixed_array\": [\n [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n ],\n [\n {\n \"type\": \"string\",\n \"value\": \"a\"\n },\n {\n \"type\": \"string\",\n \"value\": \"b\"\n },\n {\n \"type\": \"string\",\n \"value\": \"c\"\n }\n ]\n ],\n \"numbers\": [\n {\n \"type\": \"float\",\n \"value\": \"0.1\"\n },\n {\n \"type\": \"float\",\n \"value\": \"0.2\"\n },\n {\n \"type\": \"float\",\n \"value\": \"0.5\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"5\"\n }\n ],\n \"string_array\": [\n {\n \"type\": \"string\",\n \"value\": \"all\"\n },\n {\n \"type\": \"string\",\n \"value\": \"strings\"\n },\n {\n \"type\": \"string\",\n \"value\": \"are the same\"\n },\n {\n \"type\": \"string\",\n \"value\": \"type\"\n }\n ]\n}\n"
2230 testgenValid(t, input, jsonRef)
2231 }
2232
2233 func TestTOMLTest_Valid_Spec_Array1(t *testing.T) {
2234 input := "integers2 = [\n 1, 2, 3\n]\n\nintegers3 = [\n 1,\n 2, # this is ok\n]\n"
2235 jsonRef := "{\n \"integers2\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n ],\n \"integers3\": [\n {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n ]\n}\n"
2236 testgenValid(t, input, jsonRef)
2237 }
2238
2239 func TestTOMLTest_Valid_Spec_ArrayOfTables0(t *testing.T) {
2240 input := "[[products]]\nname = \"Hammer\"\nsku = 738594937\n\n[[products]] # empty table within the array\n\n[[products]]\nname = \"Nail\"\nsku = 284758393\n\ncolor = \"gray\"\n"
2241 jsonRef := "{\n \"products\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Hammer\"\n },\n \"sku\": {\n \"type\": \"integer\",\n \"value\": \"738594937\"\n }\n },\n {},\n {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"gray\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Nail\"\n },\n \"sku\": {\n \"type\": \"integer\",\n \"value\": \"284758393\"\n }\n }\n ]\n}\n"
2242 testgenValid(t, input, jsonRef)
2243 }
2244
2245 func TestTOMLTest_Valid_Spec_ArrayOfTables1(t *testing.T) {
2246 input := "[[fruits]]\nname = \"apple\"\n\n[fruits.physical] # subtable\ncolor = \"red\"\nshape = \"round\"\n\n[[fruits.varieties]] # nested array of tables\nname = \"red delicious\"\n\n[[fruits.varieties]]\nname = \"granny smith\"\n\n\n[[fruits]]\nname = \"banana\"\n\n[[fruits.varieties]]\nname = \"plantain\"\n"
2247 jsonRef := "{\n \"fruits\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"apple\"\n },\n \"physical\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n \"shape\": {\n \"type\": \"string\",\n \"value\": \"round\"\n }\n },\n \"varieties\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"red delicious\"\n }\n },\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"granny smith\"\n }\n }\n ]\n },\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"banana\"\n },\n \"varieties\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"plantain\"\n }\n }\n ]\n }\n ]\n}\n"
2248 testgenValid(t, input, jsonRef)
2249 }
2250
2251 func TestTOMLTest_Valid_Spec_ArrayOfTables2(t *testing.T) {
2252 input := "points = [ { x = 1, y = 2, z = 3 },\n { x = 7, y = 8, z = 9 },\n { x = 2, y = 4, z = 8 } ]\n"
2253 jsonRef := "{\n \"points\": [\n {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n \"z\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n },\n {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"7\"\n },\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"8\"\n },\n \"z\": {\n \"type\": \"integer\",\n \"value\": \"9\"\n }\n },\n {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"4\"\n },\n \"z\": {\n \"type\": \"integer\",\n \"value\": \"8\"\n }\n }\n ]\n}\n"
2254 testgenValid(t, input, jsonRef)
2255 }
2256
2257 func TestTOMLTest_Valid_Spec_Boolean0(t *testing.T) {
2258 input := "bool1 = true\nbool2 = false\n"
2259 jsonRef := "{\n \"bool1\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n },\n \"bool2\": {\n \"type\": \"bool\",\n \"value\": \"false\"\n }\n}\n"
2260 testgenValid(t, input, jsonRef)
2261 }
2262
2263 func TestTOMLTest_Valid_Spec_Comment0(t *testing.T) {
2264 input := "# This is a full-line comment\nkey = \"value\" # This is a comment at the end of a line\nanother = \"# This is not a comment\"\n"
2265 jsonRef := "{\n \"another\": {\n \"type\": \"string\",\n \"value\": \"# This is not a comment\"\n },\n \"key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n }\n}\n"
2266 testgenValid(t, input, jsonRef)
2267 }
2268
2269 func TestTOMLTest_Valid_Spec_Float0(t *testing.T) {
2270 input := "# fractional\nflt1 = +1.0\nflt2 = 3.1415\nflt3 = -0.01\n\n# exponent\nflt4 = 5e+22\nflt5 = 1e06\nflt6 = -2E-2\n\n# both\nflt7 = 6.626e-34\n"
2271 jsonRef := "{\n \"flt1\": {\n \"type\": \"float\",\n \"value\": \"1\"\n },\n \"flt2\": {\n \"type\": \"float\",\n \"value\": \"3.1415\"\n },\n \"flt3\": {\n \"type\": \"float\",\n \"value\": \"-0.01\"\n },\n \"flt4\": {\n \"type\": \"float\",\n \"value\": \"5e+22\"\n },\n \"flt5\": {\n \"type\": \"float\",\n \"value\": \"1e+06\"\n },\n \"flt6\": {\n \"type\": \"float\",\n \"value\": \"-0.02\"\n },\n \"flt7\": {\n \"type\": \"float\",\n \"value\": \"6.626e-34\"\n }\n}\n"
2272 testgenValid(t, input, jsonRef)
2273 }
2274
2275 func TestTOMLTest_Valid_Spec_Float1(t *testing.T) {
2276 input := "flt8 = 224_617.445_991_228\n"
2277 jsonRef := "{\n \"flt8\": {\n \"type\": \"float\",\n \"value\": \"224617.445991228\"\n }\n}\n"
2278 testgenValid(t, input, jsonRef)
2279 }
2280
2281 func TestTOMLTest_Valid_Spec_Float2(t *testing.T) {
2282 input := "# infinity\nsf1 = inf # positive infinity\nsf2 = +inf # positive infinity\nsf3 = -inf # negative infinity\n\n# not a number\nsf4 = nan # actual sNaN/qNaN encoding is implementation-specific\nsf5 = +nan # same as `nan`\nsf6 = -nan # valid, actual encoding is implementation-specific\n"
2283 jsonRef := "{\n \"sf1\": {\n \"type\": \"float\",\n \"value\": \"+inf\"\n },\n \"sf2\": {\n \"type\": \"float\",\n \"value\": \"+inf\"\n },\n \"sf3\": {\n \"type\": \"float\",\n \"value\": \"-inf\"\n },\n \"sf4\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n },\n \"sf5\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n },\n \"sf6\": {\n \"type\": \"float\",\n \"value\": \"nan\"\n }\n}\n"
2284 testgenValid(t, input, jsonRef)
2285 }
2286
2287 func TestTOMLTest_Valid_Spec_InlineTable0(t *testing.T) {
2288 input := "name = { first = \"Tom\", last = \"Preston-Werner\" }\npoint = { x = 1, y = 2 }\nanimal = { type.name = \"pug\" }\n"
2289 jsonRef := "{\n \"animal\": {\n \"type\": {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"pug\"\n }\n }\n },\n \"name\": {\n \"first\": {\n \"type\": \"string\",\n \"value\": \"Tom\"\n },\n \"last\": {\n \"type\": \"string\",\n \"value\": \"Preston-Werner\"\n }\n },\n \"point\": {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n}\n"
2290 testgenValid(t, input, jsonRef)
2291 }
2292
2293 func TestTOMLTest_Valid_Spec_InlineTable1(t *testing.T) {
2294 input := "[name]\nfirst = \"Tom\"\nlast = \"Preston-Werner\"\n\n[point]\nx = 1\ny = 2\n\n[animal]\ntype.name = \"pug\"\n"
2295 jsonRef := "{\n \"animal\": {\n \"type\": {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"pug\"\n }\n }\n },\n \"name\": {\n \"first\": {\n \"type\": \"string\",\n \"value\": \"Tom\"\n },\n \"last\": {\n \"type\": \"string\",\n \"value\": \"Preston-Werner\"\n }\n },\n \"point\": {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n },\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n}\n"
2296 testgenValid(t, input, jsonRef)
2297 }
2298
2299 func TestTOMLTest_Valid_Spec_InlineTable2(t *testing.T) {
2300 input := "[product]\ntype = { name = \"Nail\" }\n# type.edible = false # INVALID\n"
2301 jsonRef := "{\n \"product\": {\n \"type\": {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Nail\"\n }\n }\n }\n}\n"
2302 testgenValid(t, input, jsonRef)
2303 }
2304
2305 func TestTOMLTest_Valid_Spec_InlineTable3(t *testing.T) {
2306 input := "[product]\ntype.name = \"Nail\"\n# type = { edible = false } # INVALID\n"
2307 jsonRef := "{\n \"product\": {\n \"type\": {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Nail\"\n }\n }\n }\n}\n"
2308 testgenValid(t, input, jsonRef)
2309 }
2310
2311 func TestTOMLTest_Valid_Spec_Integer0(t *testing.T) {
2312 input := "int1 = +99\nint2 = 42\nint3 = 0\nint4 = -17\n"
2313 jsonRef := "{\n \"int1\": {\n \"type\": \"integer\",\n \"value\": \"99\"\n },\n \"int2\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n \"int3\": {\n \"type\": \"integer\",\n \"value\": \"0\"\n },\n \"int4\": {\n \"type\": \"integer\",\n \"value\": \"-17\"\n }\n}\n"
2314 testgenValid(t, input, jsonRef)
2315 }
2316
2317 func TestTOMLTest_Valid_Spec_Integer1(t *testing.T) {
2318 input := "int5 = 1_000\nint6 = 5_349_221\nint7 = 53_49_221 # Indian number system grouping\nint8 = 1_2_3_4_5 # VALID but discouraged\n"
2319 jsonRef := "{\n \"int5\": {\n \"type\": \"integer\",\n \"value\": \"1000\"\n },\n \"int6\": {\n \"type\": \"integer\",\n \"value\": \"5349221\"\n },\n \"int7\": {\n \"type\": \"integer\",\n \"value\": \"5349221\"\n },\n \"int8\": {\n \"type\": \"integer\",\n \"value\": \"12345\"\n }\n}\n"
2320 testgenValid(t, input, jsonRef)
2321 }
2322
2323 func TestTOMLTest_Valid_Spec_Integer2(t *testing.T) {
2324 input := "# hexadecimal with prefix `0x`\nhex1 = 0xDEADBEEF\nhex2 = 0xdeadbeef\nhex3 = 0xdead_beef\n\n# octal with prefix `0o`\noct1 = 0o01234567\noct2 = 0o755 # useful for Unix file permissions\n\n# binary with prefix `0b`\nbin1 = 0b11010110\n"
2325 jsonRef := "{\n \"bin1\": {\n \"type\": \"integer\",\n \"value\": \"214\"\n },\n \"hex1\": {\n \"type\": \"integer\",\n \"value\": \"3735928559\"\n },\n \"hex2\": {\n \"type\": \"integer\",\n \"value\": \"3735928559\"\n },\n \"hex3\": {\n \"type\": \"integer\",\n \"value\": \"3735928559\"\n },\n \"oct1\": {\n \"type\": \"integer\",\n \"value\": \"342391\"\n },\n \"oct2\": {\n \"type\": \"integer\",\n \"value\": \"493\"\n }\n}\n"
2326 testgenValid(t, input, jsonRef)
2327 }
2328
2329 func TestTOMLTest_Valid_Spec_KeyValuePair0(t *testing.T) {
2330 input := "key = \"value\"\n"
2331 jsonRef := "{\n \"key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n }\n}\n"
2332 testgenValid(t, input, jsonRef)
2333 }
2334
2335 func TestTOMLTest_Valid_Spec_Keys0(t *testing.T) {
2336 input := "key = \"value\"\nbare_key = \"value\"\nbare-key = \"value\"\n1234 = \"value\"\n"
2337 jsonRef := "{\n \"1234\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"bare-key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"bare_key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"key\": {\n \"type\": \"string\",\n \"value\": \"value\"\n }\n}\n"
2338 testgenValid(t, input, jsonRef)
2339 }
2340
2341 func TestTOMLTest_Valid_Spec_Keys1(t *testing.T) {
2342 input := "\"127.0.0.1\" = \"value\"\n\"character encoding\" = \"value\"\n\"ʎǝʞ\" = \"value\"\n'key2' = \"value\"\n'quoted \"value\"' = \"value\"\n"
2343 jsonRef := "{\n \"127.0.0.1\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"character encoding\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"key2\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"quoted \\\"value\\\"\": {\n \"type\": \"string\",\n \"value\": \"value\"\n },\n \"ʎǝʞ\": {\n \"type\": \"string\",\n \"value\": \"value\"\n }\n}\n"
2344 testgenValid(t, input, jsonRef)
2345 }
2346
2347 func TestTOMLTest_Valid_Spec_Keys3(t *testing.T) {
2348 input := "name = \"Orange\"\nphysical.color = \"orange\"\nphysical.shape = \"round\"\nsite.\"google.com\" = true\n"
2349 jsonRef := "{\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Orange\"\n },\n \"physical\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"orange\"\n },\n \"shape\": {\n \"type\": \"string\",\n \"value\": \"round\"\n }\n },\n \"site\": {\n \"google.com\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n }\n}\n"
2350 testgenValid(t, input, jsonRef)
2351 }
2352
2353 func TestTOMLTest_Valid_Spec_Keys4(t *testing.T) {
2354 input := "fruit.name = \"banana\" # this is best practice\nfruit. color = \"yellow\" # same as fruit.color\nfruit . flavor = \"banana\" # same as fruit.flavor\n"
2355 jsonRef := "{\n \"fruit\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"yellow\"\n },\n \"flavor\": {\n \"type\": \"string\",\n \"value\": \"banana\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"banana\"\n }\n }\n}\n"
2356 testgenValid(t, input, jsonRef)
2357 }
2358
2359 func TestTOMLTest_Valid_Spec_Keys5(t *testing.T) {
2360 input := "# VALID BUT DISCOURAGED\n\napple.type = \"fruit\"\norange.type = \"fruit\"\n\napple.skin = \"thin\"\norange.skin = \"thick\"\n\napple.color = \"red\"\norange.color = \"orange\"\n"
2361 jsonRef := "{\n \"apple\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n \"skin\": {\n \"type\": \"string\",\n \"value\": \"thin\"\n },\n \"type\": {\n \"type\": \"string\",\n \"value\": \"fruit\"\n }\n },\n \"orange\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"orange\"\n },\n \"skin\": {\n \"type\": \"string\",\n \"value\": \"thick\"\n },\n \"type\": {\n \"type\": \"string\",\n \"value\": \"fruit\"\n }\n }\n}\n"
2362 testgenValid(t, input, jsonRef)
2363 }
2364
2365 func TestTOMLTest_Valid_Spec_Keys6(t *testing.T) {
2366 input := "# RECOMMENDED\n\napple.type = \"fruit\"\napple.skin = \"thin\"\napple.color = \"red\"\n\norange.type = \"fruit\"\norange.skin = \"thick\"\norange.color = \"orange\"\n"
2367 jsonRef := "{\n \"apple\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n \"skin\": {\n \"type\": \"string\",\n \"value\": \"thin\"\n },\n \"type\": {\n \"type\": \"string\",\n \"value\": \"fruit\"\n }\n },\n \"orange\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"orange\"\n },\n \"skin\": {\n \"type\": \"string\",\n \"value\": \"thick\"\n },\n \"type\": {\n \"type\": \"string\",\n \"value\": \"fruit\"\n }\n }\n}\n"
2368 testgenValid(t, input, jsonRef)
2369 }
2370
2371 func TestTOMLTest_Valid_Spec_Keys7(t *testing.T) {
2372 input := "3.14159 = \"pi\"\n"
2373 jsonRef := "{\n \"3\": {\n \"14159\": {\n \"type\": \"string\",\n \"value\": \"pi\"\n }\n }\n}\n"
2374 testgenValid(t, input, jsonRef)
2375 }
2376
2377 func TestTOMLTest_Valid_Spec_LocalDate0(t *testing.T) {
2378 input := "ld1 = 1979-05-27\n"
2379 jsonRef := "{\n \"ld1\": {\n \"type\": \"date-local\",\n \"value\": \"1979-05-27\"\n }\n}\n"
2380 testgenValid(t, input, jsonRef)
2381 }
2382
2383 func TestTOMLTest_Valid_Spec_LocalDateTime0(t *testing.T) {
2384 input := "ldt1 = 1979-05-27T07:32:00\nldt2 = 1979-05-27T00:32:00.999999\n"
2385 jsonRef := "{\n \"ldt1\": {\n \"type\": \"datetime-local\",\n \"value\": \"1979-05-27T07:32:00\"\n },\n \"ldt2\": {\n \"type\": \"datetime-local\",\n \"value\": \"1979-05-27T00:32:00.999999\"\n }\n}\n"
2386 testgenValid(t, input, jsonRef)
2387 }
2388
2389 func TestTOMLTest_Valid_Spec_LocalTime0(t *testing.T) {
2390 input := "lt1 = 07:32:00\nlt2 = 00:32:00.999999\n"
2391 jsonRef := "{\n \"lt1\": {\n \"type\": \"time-local\",\n \"value\": \"07:32:00\"\n },\n \"lt2\": {\n \"type\": \"time-local\",\n \"value\": \"00:32:00.999999\"\n }\n}\n"
2392 testgenValid(t, input, jsonRef)
2393 }
2394
2395 func TestTOMLTest_Valid_Spec_OffsetDateTime0(t *testing.T) {
2396 input := "odt1 = 1979-05-27T07:32:00Z\nodt2 = 1979-05-27T00:32:00-07:00\nodt3 = 1979-05-27T00:32:00.999999-07:00\n"
2397 jsonRef := "{\n \"odt1\": {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T07:32:00Z\"\n },\n \"odt2\": {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T00:32:00-07:00\"\n },\n \"odt3\": {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T00:32:00.999999-07:00\"\n }\n}\n"
2398 testgenValid(t, input, jsonRef)
2399 }
2400
2401 func TestTOMLTest_Valid_Spec_OffsetDateTime1(t *testing.T) {
2402 input := "odt4 = 1979-05-27 07:32:00Z\n"
2403 jsonRef := "{\n \"odt4\": {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T07:32:00Z\"\n }\n}\n"
2404 testgenValid(t, input, jsonRef)
2405 }
2406
2407 func TestTOMLTest_Valid_Spec_String0(t *testing.T) {
2408 input := "str = \"I'm a string. \\\"You can quote me\\\". Name\\tJos\\u00E9\\nLocation\\tSF.\"\n"
2409 jsonRef := "{\n \"str\": {\n \"type\": \"string\",\n \"value\": \"I'm a string. \\\"You can quote me\\\". Name\\tJosé\\nLocation\\tSF.\"\n }\n}\n"
2410 testgenValid(t, input, jsonRef)
2411 }
2412
2413 func TestTOMLTest_Valid_Spec_String1(t *testing.T) {
2414 input := "str1 = \"\"\"\nRoses are red\nViolets are blue\"\"\"\n"
2415 jsonRef := "{\n \"str1\": {\n \"type\": \"string\",\n \"value\": \"Roses are red\\nViolets are blue\"\n }\n}\n"
2416 testgenValid(t, input, jsonRef)
2417 }
2418
2419 func TestTOMLTest_Valid_Spec_String2(t *testing.T) {
2420 input := "# On a Unix system, the above multi-line string will most likely be the same as:\nstr2 = \"Roses are red\\nViolets are blue\"\n\n# On a Windows system, it will most likely be equivalent to:\nstr3 = \"Roses are red\\r\\nViolets are blue\"\n"
2421 jsonRef := "{\n \"str2\": {\n \"type\": \"string\",\n \"value\": \"Roses are red\\nViolets are blue\"\n },\n \"str3\": {\n \"type\": \"string\",\n \"value\": \"Roses are red\\r\\nViolets are blue\"\n }\n}\n"
2422 testgenValid(t, input, jsonRef)
2423 }
2424
2425 func TestTOMLTest_Valid_Spec_String3(t *testing.T) {
2426 input := "# The following strings are byte-for-byte equivalent:\nstr1 = \"The quick brown fox jumps over the lazy dog.\"\n\nstr2 = \"\"\"\nThe quick brown \\\n\n\n fox jumps over \\\n the lazy dog.\"\"\"\n\nstr3 = \"\"\"\\\n The quick brown \\\n fox jumps over \\\n the lazy dog.\\\n \"\"\"\n"
2427 jsonRef := "{\n \"str1\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n },\n \"str2\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n },\n \"str3\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n }\n}\n"
2428 testgenValid(t, input, jsonRef)
2429 }
2430
2431 func TestTOMLTest_Valid_Spec_String4(t *testing.T) {
2432 input := "str4 = \"\"\"Here are two quotation marks: \"\". Simple enough.\"\"\"\n# str5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\" # INVALID\nstr5 = \"\"\"Here are three quotation marks: \"\"\\\".\"\"\"\nstr6 = \"\"\"Here are fifteen quotation marks: \"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\".\"\"\"\n\n# \"This,\" she said, \"is just a pointless statement.\"\nstr7 = \"\"\"\"This,\" she said, \"is just a pointless statement.\"\"\"\"\n"
2433 jsonRef := "{\n \"str4\": {\n \"type\": \"string\",\n \"value\": \"Here are two quotation marks: \\\"\\\". Simple enough.\"\n },\n \"str5\": {\n \"type\": \"string\",\n \"value\": \"Here are three quotation marks: \\\"\\\"\\\".\"\n },\n \"str6\": {\n \"type\": \"string\",\n \"value\": \"Here are fifteen quotation marks: \\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\".\"\n },\n \"str7\": {\n \"type\": \"string\",\n \"value\": \"\\\"This,\\\" she said, \\\"is just a pointless statement.\\\"\"\n }\n}\n"
2434 testgenValid(t, input, jsonRef)
2435 }
2436
2437 func TestTOMLTest_Valid_Spec_String5(t *testing.T) {
2438 input := "# What you see is what you get.\nwinpath = 'C:\\Users\\nodejs\\templates'\nwinpath2 = '\\\\ServerX\\admin$\\system32\\'\nquoted = 'Tom \"Dubs\" Preston-Werner'\nregex = '<\\i\\c*\\s*>'\n"
2439 jsonRef := "{\n \"quoted\": {\n \"type\": \"string\",\n \"value\": \"Tom \\\"Dubs\\\" Preston-Werner\"\n },\n \"regex\": {\n \"type\": \"string\",\n \"value\": \"\\u003c\\\\i\\\\c*\\\\s*\\u003e\"\n },\n \"winpath\": {\n \"type\": \"string\",\n \"value\": \"C:\\\\Users\\\\nodejs\\\\templates\"\n },\n \"winpath2\": {\n \"type\": \"string\",\n \"value\": \"\\\\\\\\ServerX\\\\admin$\\\\system32\\\\\"\n }\n}\n"
2440 testgenValid(t, input, jsonRef)
2441 }
2442
2443 func TestTOMLTest_Valid_Spec_String6(t *testing.T) {
2444 input := "regex2 = '''I [dw]on't need \\d{2} apples'''\nlines = '''\nThe first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n'''\n"
2445 jsonRef := "{\n \"lines\": {\n \"type\": \"string\",\n \"value\": \"The first newline is\\ntrimmed in raw strings.\\n All other whitespace\\n is preserved.\\n\"\n },\n \"regex2\": {\n \"type\": \"string\",\n \"value\": \"I [dw]on't need \\\\d{2} apples\"\n }\n}\n"
2446 testgenValid(t, input, jsonRef)
2447 }
2448
2449 func TestTOMLTest_Valid_Spec_String7(t *testing.T) {
2450 input := "quot15 = '''Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"'''\n\n# apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID\napos15 = \"Here are fifteen apostrophes: '''''''''''''''\"\n\n# 'That,' she said, 'is still pointless.'\nstr = ''''That,' she said, 'is still pointless.''''\n"
2451 jsonRef := "{\n \"apos15\": {\n \"type\": \"string\",\n \"value\": \"Here are fifteen apostrophes: '''''''''''''''\"\n },\n \"quot15\": {\n \"type\": \"string\",\n \"value\": \"Here are fifteen quotation marks: \\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\"\n },\n \"str\": {\n \"type\": \"string\",\n \"value\": \"'That,' she said, 'is still pointless.'\"\n }\n}\n"
2452 testgenValid(t, input, jsonRef)
2453 }
2454
2455 func TestTOMLTest_Valid_Spec_Table0(t *testing.T) {
2456 input := "[table]\n"
2457 jsonRef := "{\n \"table\": {}\n}\n"
2458 testgenValid(t, input, jsonRef)
2459 }
2460
2461 func TestTOMLTest_Valid_Spec_Table1(t *testing.T) {
2462 input := "[table-1]\nkey1 = \"some string\"\nkey2 = 123\n\n[table-2]\nkey1 = \"another string\"\nkey2 = 456\n"
2463 jsonRef := "{\n \"table-1\": {\n \"key1\": {\n \"type\": \"string\",\n \"value\": \"some string\"\n },\n \"key2\": {\n \"type\": \"integer\",\n \"value\": \"123\"\n }\n },\n \"table-2\": {\n \"key1\": {\n \"type\": \"string\",\n \"value\": \"another string\"\n },\n \"key2\": {\n \"type\": \"integer\",\n \"value\": \"456\"\n }\n }\n}\n"
2464 testgenValid(t, input, jsonRef)
2465 }
2466
2467 func TestTOMLTest_Valid_Spec_Table2(t *testing.T) {
2468 input := "[dog.\"tater.man\"]\ntype.name = \"pug\"\n"
2469 jsonRef := "{\n \"dog\": {\n \"tater.man\": {\n \"type\": {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"pug\"\n }\n }\n }\n }\n}\n"
2470 testgenValid(t, input, jsonRef)
2471 }
2472
2473 func TestTOMLTest_Valid_Spec_Table3(t *testing.T) {
2474 input := "[a.b.c] # this is best practice\n[ d.e.f ] # same as [d.e.f]\n[ g . h . i ] # same as [g.h.i]\n[ j . \"ʞ\" . 'l' ] # same as [j.\"ʞ\".'l']\n"
2475 jsonRef := "{\n \"a\": {\n \"b\": {\n \"c\": {}\n }\n },\n \"d\": {\n \"e\": {\n \"f\": {}\n }\n },\n \"g\": {\n \"h\": {\n \"i\": {}\n }\n },\n \"j\": {\n \"ʞ\": {\n \"l\": {}\n }\n }\n}\n"
2476 testgenValid(t, input, jsonRef)
2477 }
2478
2479 func TestTOMLTest_Valid_Spec_Table4(t *testing.T) {
2480 input := "# [x] you\n# [x.y] don't\n# [x.y.z] need these\n[x.y.z.w] # for this to work\n\n[x] # defining a super-table afterward is ok\n"
2481 jsonRef := "{\n \"x\": {\n \"y\": {\n \"z\": {\n \"w\": {}\n }\n }\n }\n}\n"
2482 testgenValid(t, input, jsonRef)
2483 }
2484
2485 func TestTOMLTest_Valid_Spec_Table5(t *testing.T) {
2486 input := "# VALID BUT DISCOURAGED\n[fruit.apple]\n[animal]\n[fruit.orange]\n"
2487 jsonRef := "{\n \"animal\": {},\n \"fruit\": {\n \"apple\": {},\n \"orange\": {}\n }\n}\n"
2488 testgenValid(t, input, jsonRef)
2489 }
2490
2491 func TestTOMLTest_Valid_Spec_Table6(t *testing.T) {
2492 input := "# RECOMMENDED\n[fruit.apple]\n[fruit.orange]\n[animal]\n"
2493 jsonRef := "{\n \"animal\": {},\n \"fruit\": {\n \"apple\": {},\n \"orange\": {}\n }\n}\n"
2494 testgenValid(t, input, jsonRef)
2495 }
2496
2497 func TestTOMLTest_Valid_Spec_Table7(t *testing.T) {
2498 input := "# Top-level table begins.\nname = \"Fido\"\nbreed = \"pug\"\n\n# Top-level table ends.\n[owner]\nname = \"Regina Dogman\"\nmember_since = 1999-08-04\n"
2499 jsonRef := "{\n \"breed\": {\n \"type\": \"string\",\n \"value\": \"pug\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Fido\"\n },\n \"owner\": {\n \"member_since\": {\n \"type\": \"date-local\",\n \"value\": \"1999-08-04\"\n },\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Regina Dogman\"\n }\n }\n}\n"
2500 testgenValid(t, input, jsonRef)
2501 }
2502
2503 func TestTOMLTest_Valid_Spec_Table8(t *testing.T) {
2504 input := "fruit.apple.color = \"red\"\n# Defines a table named fruit\n# Defines a table named fruit.apple\n\nfruit.apple.taste.sweet = true\n# Defines a table named fruit.apple.taste\n# fruit and fruit.apple were already created\n"
2505 jsonRef := "{\n \"fruit\": {\n \"apple\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n \"taste\": {\n \"sweet\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n }\n }\n }\n}\n"
2506 testgenValid(t, input, jsonRef)
2507 }
2508
2509 func TestTOMLTest_Valid_Spec_Table9(t *testing.T) {
2510 input := "[fruit]\napple.color = \"red\"\napple.taste.sweet = true\n\n# [fruit.apple] # INVALID\n# [fruit.apple.taste] # INVALID\n\n[fruit.apple.texture] # you can add sub-tables\nsmooth = true\n"
2511 jsonRef := "{\n \"fruit\": {\n \"apple\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n \"taste\": {\n \"sweet\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n },\n \"texture\": {\n \"smooth\": {\n \"type\": \"bool\",\n \"value\": \"true\"\n }\n }\n }\n }\n}\n"
2512 testgenValid(t, input, jsonRef)
2513 }
2514
2515 func TestTOMLTest_Valid_String_DoubleQuoteEscape(t *testing.T) {
2516 input := "test = \"\\\"one\\\"\"\n"
2517 jsonRef := "{\n \"test\": {\n \"type\": \"string\",\n \"value\": \"\\\"one\\\"\"\n }\n}\n"
2518 testgenValid(t, input, jsonRef)
2519 }
2520
2521 func TestTOMLTest_Valid_String_Empty(t *testing.T) {
2522 input := "answer = \"\"\n"
2523 jsonRef := "{\n \"answer\": {\n \"type\": \"string\",\n \"value\": \"\"\n }\n}\n"
2524 testgenValid(t, input, jsonRef)
2525 }
2526
2527 func TestTOMLTest_Valid_String_EndsInWhitespaceEscape(t *testing.T) {
2528 input := "beee = \"\"\"\nheeee\ngeeee\\ \n\n\n \"\"\"\n"
2529 jsonRef := "{\n \"beee\": {\n \"type\": \"string\",\n \"value\": \"heeee\\ngeeee\"\n }\n}\n"
2530 testgenValid(t, input, jsonRef)
2531 }
2532
2533 func TestTOMLTest_Valid_String_EscapeTricky(t *testing.T) {
2534 input := "end_esc = \"String does not end here\\\" but ends here\\\\\"\nlit_end_esc = 'String ends here\\'\n\nmultiline_unicode = \"\"\"\n\\u00a0\"\"\"\n\nmultiline_not_unicode = \"\"\"\n\\\\u0041\"\"\"\n\nmultiline_end_esc = \"\"\"When will it end? \\\"\"\"...\"\"\\\" should be here\\\"\"\"\"\n\nlit_multiline_not_unicode = '''\n\\u007f'''\n\nlit_multiline_end = '''There is no escape\\'''\n"
2535 jsonRef := "{\n \"end_esc\": {\n \"type\": \"string\",\n \"value\": \"String does not end here\\\" but ends here\\\\\"\n },\n \"lit_end_esc\": {\n \"type\": \"string\",\n \"value\": \"String ends here\\\\\"\n },\n \"lit_multiline_end\": {\n \"type\": \"string\",\n \"value\": \"There is no escape\\\\\"\n },\n \"lit_multiline_not_unicode\": {\n \"type\": \"string\",\n \"value\": \"\\\\u007f\"\n },\n \"multiline_end_esc\": {\n \"type\": \"string\",\n \"value\": \"When will it end? \\\"\\\"\\\"...\\\"\\\"\\\" should be here\\\"\"\n },\n \"multiline_not_unicode\": {\n \"type\": \"string\",\n \"value\": \"\\\\u0041\"\n },\n \"multiline_unicode\": {\n \"type\": \"string\",\n \"value\": \"\u00a0\"\n }\n}\n"
2536 testgenValid(t, input, jsonRef)
2537 }
2538
2539 func TestTOMLTest_Valid_String_EscapedEscape(t *testing.T) {
2540 input := "answer = \"\\\\x64\"\n"
2541 jsonRef := "{\n \"answer\": {\n \"type\": \"string\",\n \"value\": \"\\\\x64\"\n }\n}\n"
2542 testgenValid(t, input, jsonRef)
2543 }
2544
2545 func TestTOMLTest_Valid_String_Escapes(t *testing.T) {
2546 input := "backspace = \"This string has a \\b backspace character.\"\ntab = \"This string has a \\t tab character.\"\nnewline = \"This string has a \\n new line character.\"\nformfeed = \"This string has a \\f form feed character.\"\ncarriage = \"This string has a \\r carriage return character.\"\nquote = \"This string has a \\\" quote character.\"\nbackslash = \"This string has a \\\\ backslash character.\"\nnotunicode1 = \"This string does not have a unicode \\\\u escape.\"\nnotunicode2 = \"This string does not have a unicode \\u005Cu escape.\"\nnotunicode3 = \"This string does not have a unicode \\\\u0075 escape.\"\nnotunicode4 = \"This string does not have a unicode \\\\\\u0075 escape.\"\ndelete = \"This string has a \\u007F delete control code.\"\nunitseparator = \"This string has a \\u001F unit separator control code.\"\n"
2547 jsonRef := "{\n \"backslash\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\ backslash character.\"\n },\n \"backspace\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\u0008 backspace character.\"\n },\n \"carriage\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\r carriage return character.\"\n },\n \"delete\": {\n \"type\": \"string\",\n \"value\": \"This string has a \x7f delete control code.\"\n },\n \"formfeed\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\u000c form feed character.\"\n },\n \"newline\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\n new line character.\"\n },\n \"notunicode1\": {\n \"type\": \"string\",\n \"value\": \"This string does not have a unicode \\\\u escape.\"\n },\n \"notunicode2\": {\n \"type\": \"string\",\n \"value\": \"This string does not have a unicode \\\\u escape.\"\n },\n \"notunicode3\": {\n \"type\": \"string\",\n \"value\": \"This string does not have a unicode \\\\u0075 escape.\"\n },\n \"notunicode4\": {\n \"type\": \"string\",\n \"value\": \"This string does not have a unicode \\\\u escape.\"\n },\n \"quote\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\" quote character.\"\n },\n \"tab\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\t tab character.\"\n },\n \"unitseparator\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\u001f unit separator control code.\"\n }\n}\n"
2548 testgenValid(t, input, jsonRef)
2549 }
2550
2551 func TestTOMLTest_Valid_String_MultilineEscapedCrlf(t *testing.T) {
2552 input := "# The following line should be an unescaped backslash followed by a Windows\r\n# newline sequence (\"\\r\\n\")\r\n0=\"\"\"\\\r\n\"\"\"\r\n"
2553 jsonRef := "{\n \"0\": {\n \"type\": \"string\",\n \"value\": \"\"\n }\n}\n"
2554 testgenValid(t, input, jsonRef)
2555 }
2556
2557 func TestTOMLTest_Valid_String_MultilineQuotes(t *testing.T) {
2558 input := "# Make sure that quotes inside multiline strings are allowed, including right\n# after the opening '''/\"\"\" and before the closing '''/\"\"\"\n\nlit_one = ''''one quote''''\nlit_two = '''''two quotes'''''\nlit_one_space = ''' 'one quote' '''\nlit_two_space = ''' ''two quotes'' '''\n\none = \"\"\"\"one quote\"\"\"\"\ntwo = \"\"\"\"\"two quotes\"\"\"\"\"\none_space = \"\"\" \"one quote\" \"\"\"\ntwo_space = \"\"\" \"\"two quotes\"\" \"\"\"\n\nmismatch1 = \"\"\"aaa'''bbb\"\"\"\nmismatch2 = '''aaa\"\"\"bbb'''\n\n# Three opening \"\"\", then one escaped \", then two \"\" (allowed), and then three\n# closing \"\"\"\nescaped = \"\"\"lol\\\"\"\"\"\"\"\n\nfive-quotes = \"\"\"\nClosing with five quotes\n\"\"\"\"\"\nfour-quotes = \"\"\"\nClosing with four quotes\n\"\"\"\"\n"
2559 jsonRef := "{\n \"escaped\": {\n \"type\": \"string\",\n \"value\": \"lol\\\"\\\"\\\"\"\n },\n \"five-quotes\": {\n \"type\": \"string\",\n \"value\": \"Closing with five quotes\\n\\\"\\\"\"\n },\n \"four-quotes\": {\n \"type\": \"string\",\n \"value\": \"Closing with four quotes\\n\\\"\"\n },\n \"lit_one\": {\n \"type\": \"string\",\n \"value\": \"'one quote'\"\n },\n \"lit_one_space\": {\n \"type\": \"string\",\n \"value\": \" 'one quote' \"\n },\n \"lit_two\": {\n \"type\": \"string\",\n \"value\": \"''two quotes''\"\n },\n \"lit_two_space\": {\n \"type\": \"string\",\n \"value\": \" ''two quotes'' \"\n },\n \"mismatch1\": {\n \"type\": \"string\",\n \"value\": \"aaa'''bbb\"\n },\n \"mismatch2\": {\n \"type\": \"string\",\n \"value\": \"aaa\\\"\\\"\\\"bbb\"\n },\n \"one\": {\n \"type\": \"string\",\n \"value\": \"\\\"one quote\\\"\"\n },\n \"one_space\": {\n \"type\": \"string\",\n \"value\": \" \\\"one quote\\\" \"\n },\n \"two\": {\n \"type\": \"string\",\n \"value\": \"\\\"\\\"two quotes\\\"\\\"\"\n },\n \"two_space\": {\n \"type\": \"string\",\n \"value\": \" \\\"\\\"two quotes\\\"\\\" \"\n }\n}\n"
2560 testgenValid(t, input, jsonRef)
2561 }
2562
2563 func TestTOMLTest_Valid_String_Multiline(t *testing.T) {
2564 input := "# NOTE: this file includes some literal tab characters.\n\nmultiline_empty_one = \"\"\"\"\"\"\n\n# A newline immediately following the opening delimiter will be trimmed.\nmultiline_empty_two = \"\"\"\n\"\"\"\n\n# \\ at the end of line trims newlines as well; note that last \\ is followed by\n# two spaces, which are ignored.\nmultiline_empty_three = \"\"\"\\\n \"\"\"\nmultiline_empty_four = \"\"\"\\\n \\\n \\ \n \"\"\"\n\nequivalent_one = \"The quick brown fox jumps over the lazy dog.\"\nequivalent_two = \"\"\"\nThe quick brown \\\n\n\n fox jumps over \\\n the lazy dog.\"\"\"\n\nequivalent_three = \"\"\"\\\n The quick brown \\\n fox jumps over \\\n the lazy dog.\\\n \"\"\"\n\nwhitespace-after-bs = \"\"\"\\\n The quick brown \\\n fox jumps over \\ \n the lazy dog.\\\t\n \"\"\"\n\nno-space = \"\"\"a\\\n b\"\"\"\n\n# Has tab character.\nkeep-ws-before = \"\"\"a \t\\\n b\"\"\"\n\nescape-bs-1 = \"\"\"a \\\\\nb\"\"\"\n\nescape-bs-2 = \"\"\"a \\\\\\\nb\"\"\"\n\nescape-bs-3 = \"\"\"a \\\\\\\\\n b\"\"\"\n"
2565 jsonRef := "{\n \"equivalent_one\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n },\n \"equivalent_three\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n },\n \"equivalent_two\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n },\n \"escape-bs-1\": {\n \"type\": \"string\",\n \"value\": \"a \\\\\\nb\"\n },\n \"escape-bs-2\": {\n \"type\": \"string\",\n \"value\": \"a \\\\b\"\n },\n \"escape-bs-3\": {\n \"type\": \"string\",\n \"value\": \"a \\\\\\\\\\n b\"\n },\n \"keep-ws-before\": {\n \"type\": \"string\",\n \"value\": \"a \\tb\"\n },\n \"multiline_empty_four\": {\n \"type\": \"string\",\n \"value\": \"\"\n },\n \"multiline_empty_one\": {\n \"type\": \"string\",\n \"value\": \"\"\n },\n \"multiline_empty_three\": {\n \"type\": \"string\",\n \"value\": \"\"\n },\n \"multiline_empty_two\": {\n \"type\": \"string\",\n \"value\": \"\"\n },\n \"no-space\": {\n \"type\": \"string\",\n \"value\": \"ab\"\n },\n \"whitespace-after-bs\": {\n \"type\": \"string\",\n \"value\": \"The quick brown fox jumps over the lazy dog.\"\n }\n}\n"
2566 testgenValid(t, input, jsonRef)
2567 }
2568
2569 func TestTOMLTest_Valid_String_Nl(t *testing.T) {
2570 input := "nl_mid = \"val\\nue\"\nnl_end = \"\"\"value\\n\"\"\"\n\nlit_nl_end = '''value\\n'''\nlit_nl_mid = 'val\\nue'\nlit_nl_uni = 'val\\ue'\n"
2571 jsonRef := "{\n \"lit_nl_end\": {\n \"type\": \"string\",\n \"value\": \"value\\\\n\"\n },\n \"lit_nl_mid\": {\n \"type\": \"string\",\n \"value\": \"val\\\\nue\"\n },\n \"lit_nl_uni\": {\n \"type\": \"string\",\n \"value\": \"val\\\\ue\"\n },\n \"nl_end\": {\n \"type\": \"string\",\n \"value\": \"value\\n\"\n },\n \"nl_mid\": {\n \"type\": \"string\",\n \"value\": \"val\\nue\"\n }\n}\n"
2572 testgenValid(t, input, jsonRef)
2573 }
2574
2575 func TestTOMLTest_Valid_String_QuotedUnicode(t *testing.T) {
2576 input := "\nescaped_string = \"\\u0000 \\u0008 \\u000c \\U00000041 \\u007f \\u0080 \\u00ff \\ud7ff \\ue000 \\uffff \\U00010000 \\U0010ffff\"\nnot_escaped_string = '\\u0000 \\u0008 \\u000c \\U00000041 \\u007f \\u0080 \\u00ff \\ud7ff \\ue000 \\uffff \\U00010000 \\U0010ffff'\n\nbasic_string = \"~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\"\nliteral_string = '~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff'\n"
2577 jsonRef := "{\n \"basic_string\": {\n \"type\": \"string\",\n \"value\": \"~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\"\n },\n \"escaped_string\": {\n \"type\": \"string\",\n \"value\": \"\\u0000 \\u0008 \\u000c A \x7f \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\"\n },\n \"literal_string\": {\n \"type\": \"string\",\n \"value\": \"~ \u0080 ÿ \ud7ff \ue000 \uffff 𐀀 \U0010ffff\"\n },\n \"not_escaped_string\": {\n \"type\": \"string\",\n \"value\": \"\\\\u0000 \\\\u0008 \\\\u000c \\\\U00000041 \\\\u007f \\\\u0080 \\\\u00ff \\\\ud7ff \\\\ue000 \\\\uffff \\\\U00010000 \\\\U0010ffff\"\n }\n}\n"
2578 testgenValid(t, input, jsonRef)
2579 }
2580
2581 func TestTOMLTest_Valid_String_RawMultiline(t *testing.T) {
2582 input := "# Single ' should be allowed.\noneline = '''This string has a ' quote character.'''\n\n# A newline immediately following the opening delimiter will be trimmed.\nfirstnl = '''\nThis string has a ' quote character.'''\n\n# All other whitespace and newline characters remain intact.\nmultiline = '''\nThis string\nhas ' a quote character\nand more than\none newline\nin it.'''\n\n# Tab character in literal string does not need to be escaped\nmultiline_with_tab = '''First line\n\t Followed by a tab'''\n\nthis-str-has-apostrophes='''' there's one already\n'' two more\n'''''\n"
2583 jsonRef := "{\n \"firstnl\": {\n \"type\": \"string\",\n \"value\": \"This string has a ' quote character.\"\n },\n \"multiline\": {\n \"type\": \"string\",\n \"value\": \"This string\\nhas ' a quote character\\nand more than\\none newline\\nin it.\"\n },\n \"multiline_with_tab\": {\n \"type\": \"string\",\n \"value\": \"First line\\n\\t Followed by a tab\"\n },\n \"oneline\": {\n \"type\": \"string\",\n \"value\": \"This string has a ' quote character.\"\n },\n \"this-str-has-apostrophes\": {\n \"type\": \"string\",\n \"value\": \"' there's one already\\n'' two more\\n''\"\n }\n}\n"
2584 testgenValid(t, input, jsonRef)
2585 }
2586
2587 func TestTOMLTest_Valid_String_Raw(t *testing.T) {
2588 input := "backspace = 'This string has a \\b backspace character.'\ntab = 'This string has a \\t tab character.'\nunescaped_tab = 'This string has an \t unescaped tab character.'\nnewline = 'This string has a \\n new line character.'\nformfeed = 'This string has a \\f form feed character.'\ncarriage = 'This string has a \\r carriage return character.'\nslash = 'This string has a \\/ slash character.'\nbackslash = 'This string has a \\\\ backslash character.'\n"
2589 jsonRef := "{\n \"backslash\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\\\\\ backslash character.\"\n },\n \"backspace\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\b backspace character.\"\n },\n \"carriage\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\r carriage return character.\"\n },\n \"formfeed\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\f form feed character.\"\n },\n \"newline\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\n new line character.\"\n },\n \"slash\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\/ slash character.\"\n },\n \"tab\": {\n \"type\": \"string\",\n \"value\": \"This string has a \\\\t tab character.\"\n },\n \"unescaped_tab\": {\n \"type\": \"string\",\n \"value\": \"This string has an \\t unescaped tab character.\"\n }\n}\n"
2590 testgenValid(t, input, jsonRef)
2591 }
2592
2593 func TestTOMLTest_Valid_String_Simple(t *testing.T) {
2594 input := "answer = \"You are not drinking enough whisky.\"\n"
2595 jsonRef := "{\n \"answer\": {\n \"type\": \"string\",\n \"value\": \"You are not drinking enough whisky.\"\n }\n}\n"
2596 testgenValid(t, input, jsonRef)
2597 }
2598
2599 func TestTOMLTest_Valid_String_UnicodeEscape(t *testing.T) {
2600 input := "delta-1 = \"\\u03B4\"\ndelta-2 = \"\\U000003B4\"\na = \"\\u0061\"\nb = \"\\u0062\"\nc = \"\\U00000063\"\nnull-1 = \"\\u0000\"\nnull-2 = \"\\U00000000\"\n\nml-delta-1 = \"\"\"\\u03B4\"\"\"\nml-delta-2 = \"\"\"\\U000003B4\"\"\"\nml-a = \"\"\"\\u0061\"\"\"\nml-b = \"\"\"\\u0062\"\"\"\nml-c = \"\"\"\\U00000063\"\"\"\nml-null-1 = \"\"\"\\u0000\"\"\"\nml-null-2 = \"\"\"\\U00000000\"\"\"\n"
2601 jsonRef := "{\n \"a\": {\n \"type\": \"string\",\n \"value\": \"a\"\n },\n \"b\": {\n \"type\": \"string\",\n \"value\": \"b\"\n },\n \"c\": {\n \"type\": \"string\",\n \"value\": \"c\"\n },\n \"delta-1\": {\n \"type\": \"string\",\n \"value\": \"δ\"\n },\n \"delta-2\": {\n \"type\": \"string\",\n \"value\": \"δ\"\n },\n \"ml-a\": {\n \"type\": \"string\",\n \"value\": \"a\"\n },\n \"ml-b\": {\n \"type\": \"string\",\n \"value\": \"b\"\n },\n \"ml-c\": {\n \"type\": \"string\",\n \"value\": \"c\"\n },\n \"ml-delta-1\": {\n \"type\": \"string\",\n \"value\": \"δ\"\n },\n \"ml-delta-2\": {\n \"type\": \"string\",\n \"value\": \"δ\"\n },\n \"ml-null-1\": {\n \"type\": \"string\",\n \"value\": \"\\u0000\"\n },\n \"ml-null-2\": {\n \"type\": \"string\",\n \"value\": \"\\u0000\"\n },\n \"null-1\": {\n \"type\": \"string\",\n \"value\": \"\\u0000\"\n },\n \"null-2\": {\n \"type\": \"string\",\n \"value\": \"\\u0000\"\n }\n}\n"
2602 testgenValid(t, input, jsonRef)
2603 }
2604
2605 func TestTOMLTest_Valid_String_UnicodeLiteral(t *testing.T) {
2606 input := "answer = \"δ\"\n"
2607 jsonRef := "{\n \"answer\": {\n \"type\": \"string\",\n \"value\": \"δ\"\n }\n}\n"
2608 testgenValid(t, input, jsonRef)
2609 }
2610
2611 func TestTOMLTest_Valid_String_WithPound(t *testing.T) {
2612 input := "pound = \"We see no # comments here.\"\npoundcomment = \"But there are # some comments here.\" # Did I # mess you up?\n"
2613 jsonRef := "{\n \"pound\": {\n \"type\": \"string\",\n \"value\": \"We see no # comments here.\"\n },\n \"poundcomment\": {\n \"type\": \"string\",\n \"value\": \"But there are # some comments here.\"\n }\n}\n"
2614 testgenValid(t, input, jsonRef)
2615 }
2616
2617 func TestTOMLTest_Valid_Table_ArrayImplicitAndExplicitAfter(t *testing.T) {
2618 input := "[[a.b]]\nx = 1\n\n[a]\ny = 2\n"
2619 jsonRef := "{\n \"a\": {\n \"b\": [\n {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n ],\n \"y\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n}\n"
2620 testgenValid(t, input, jsonRef)
2621 }
2622
2623 func TestTOMLTest_Valid_Table_ArrayImplicit(t *testing.T) {
2624 input := "[[albums.songs]]\nname = \"Glory Days\"\n"
2625 jsonRef := "{\n \"albums\": {\n \"songs\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Glory Days\"\n }\n }\n ]\n }\n}\n"
2626 testgenValid(t, input, jsonRef)
2627 }
2628
2629 func TestTOMLTest_Valid_Table_ArrayMany(t *testing.T) {
2630 input := "[[people]]\nfirst_name = \"Bruce\"\nlast_name = \"Springsteen\"\n\n[[people]]\nfirst_name = \"Eric\"\nlast_name = \"Clapton\"\n\n[[people]]\nfirst_name = \"Bob\"\nlast_name = \"Seger\"\n"
2631 jsonRef := "{\n \"people\": [\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Bruce\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Springsteen\"\n }\n },\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Eric\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Clapton\"\n }\n },\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Bob\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Seger\"\n }\n }\n ]\n}\n"
2632 testgenValid(t, input, jsonRef)
2633 }
2634
2635 func TestTOMLTest_Valid_Table_ArrayNest(t *testing.T) {
2636 input := "[[albums]]\nname = \"Born to Run\"\n\n [[albums.songs]]\n name = \"Jungleland\"\n\n [[albums.songs]]\n name = \"Meeting Across the River\"\n\n[[albums]]\nname = \"Born in the USA\"\n \n [[albums.songs]]\n name = \"Glory Days\"\n\n [[albums.songs]]\n name = \"Dancing in the Dark\"\n"
2637 jsonRef := "{\n \"albums\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Born to Run\"\n },\n \"songs\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Jungleland\"\n }\n },\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Meeting Across the River\"\n }\n }\n ]\n },\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Born in the USA\"\n },\n \"songs\": [\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Glory Days\"\n }\n },\n {\n \"name\": {\n \"type\": \"string\",\n \"value\": \"Dancing in the Dark\"\n }\n }\n ]\n }\n ]\n}\n"
2638 testgenValid(t, input, jsonRef)
2639 }
2640
2641 func TestTOMLTest_Valid_Table_ArrayOne(t *testing.T) {
2642 input := "[[people]]\nfirst_name = \"Bruce\"\nlast_name = \"Springsteen\"\n"
2643 jsonRef := "{\n \"people\": [\n {\n \"first_name\": {\n \"type\": \"string\",\n \"value\": \"Bruce\"\n },\n \"last_name\": {\n \"type\": \"string\",\n \"value\": \"Springsteen\"\n }\n }\n ]\n}\n"
2644 testgenValid(t, input, jsonRef)
2645 }
2646
2647 func TestTOMLTest_Valid_Table_ArrayTableArray(t *testing.T) {
2648 input := "[[a]]\n [[a.b]]\n [a.b.c]\n d = \"val0\"\n [[a.b]]\n [a.b.c]\n d = \"val1\"\n"
2649 jsonRef := "{\n \"a\": [\n {\n \"b\": [\n {\n \"c\": {\n \"d\": {\n \"type\": \"string\",\n \"value\": \"val0\"\n }\n }\n },\n {\n \"c\": {\n \"d\": {\n \"type\": \"string\",\n \"value\": \"val1\"\n }\n }\n }\n ]\n }\n ]\n}\n"
2650 testgenValid(t, input, jsonRef)
2651 }
2652
2653 func TestTOMLTest_Valid_Table_ArrayWithinDotted(t *testing.T) {
2654 input := "[fruit]\napple.color = \"red\"\n\n[[fruit.apple.seeds]]\nsize = 2\n"
2655 jsonRef := "{\n \"fruit\": {\n \"apple\": {\n \"color\": {\n \"type\": \"string\",\n \"value\": \"red\"\n },\n \"seeds\": [\n {\n \"size\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n }\n ]\n }\n }\n}\n"
2656 testgenValid(t, input, jsonRef)
2657 }
2658
2659 func TestTOMLTest_Valid_Table_EmptyName(t *testing.T) {
2660 input := "['']\nx = 1\n\n[\"\".a]\nx = 2\n\n[a.'']\nx = 3\n"
2661 jsonRef := "{\n \"\": {\n \"a\": {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n }\n },\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n },\n \"a\": {\n \"\": {\n \"x\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n }\n }\n}\n"
2662 testgenValid(t, input, jsonRef)
2663 }
2664
2665 func TestTOMLTest_Valid_Table_Empty(t *testing.T) {
2666 input := "[a]\n"
2667 jsonRef := "{\n \"a\": {}\n}\n"
2668 testgenValid(t, input, jsonRef)
2669 }
2670
2671 func TestTOMLTest_Valid_Table_Keyword(t *testing.T) {
2672 input := "[true]\n\n[false]\n\n[inf]\n\n[nan]\n\n\n"
2673 jsonRef := "{\n \"false\": {},\n \"inf\": {},\n \"nan\": {},\n \"true\": {}\n}\n"
2674 testgenValid(t, input, jsonRef)
2675 }
2676
2677 func TestTOMLTest_Valid_Table_Names(t *testing.T) {
2678 input := "[a.b.c]\n[a.\"b.c\"]\n[a.'d.e']\n[a.' x ']\n[ d.e.f ]\n[ g . h . i ]\n[ j . \"ʞ\" . 'l' ]\n\n[x.1.2]\n"
2679 jsonRef := "{\n \"a\": {\n \" x \": {},\n \"b\": {\n \"c\": {}\n },\n \"b.c\": {},\n \"d.e\": {}\n },\n \"d\": {\n \"e\": {\n \"f\": {}\n }\n },\n \"g\": {\n \"h\": {\n \"i\": {}\n }\n },\n \"j\": {\n \"ʞ\": {\n \"l\": {}\n }\n },\n \"x\": {\n \"1\": {\n \"2\": {}\n }\n }\n}\n"
2680 testgenValid(t, input, jsonRef)
2681 }
2682
2683 func TestTOMLTest_Valid_Table_NoEol(t *testing.T) {
2684 input := "[table]\n"
2685 jsonRef := "{\n \"table\": {}\n}\n"
2686 testgenValid(t, input, jsonRef)
2687 }
2688
2689 func TestTOMLTest_Valid_Table_SubEmpty(t *testing.T) {
2690 input := "[a]\n[a.b]\n"
2691 jsonRef := "{\n \"a\": {\n \"b\": {}\n }\n}\n"
2692 testgenValid(t, input, jsonRef)
2693 }
2694
2695 func TestTOMLTest_Valid_Table_Sub(t *testing.T) {
2696 input := "[a]\nkey = 1\n\n# a.extend is a key inside the \"a\" table.\n[a.extend]\nkey = 2\n\n[a.extend.more]\nkey = 3\n"
2697 jsonRef := "{\n \"a\": {\n \"extend\": {\n \"key\": {\n \"type\": \"integer\",\n \"value\": \"2\"\n },\n \"more\": {\n \"key\": {\n \"type\": \"integer\",\n \"value\": \"3\"\n }\n }\n },\n \"key\": {\n \"type\": \"integer\",\n \"value\": \"1\"\n }\n }\n}\n"
2698 testgenValid(t, input, jsonRef)
2699 }
2700
2701 func TestTOMLTest_Valid_Table_Whitespace(t *testing.T) {
2702 input := "[\"valid key\"]\n"
2703 jsonRef := "{\n \"valid key\": {}\n}\n"
2704 testgenValid(t, input, jsonRef)
2705 }
2706
2707 func TestTOMLTest_Valid_Table_WithLiteralString(t *testing.T) {
2708 input := "['a']\n[a.'\"b\"']\n[a.'\"b\"'.c]\nanswer = 42 \n"
2709 jsonRef := "{\n \"a\": {\n \"\\\"b\\\"\": {\n \"c\": {\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n }\n }\n }\n}\n"
2710 testgenValid(t, input, jsonRef)
2711 }
2712
2713 func TestTOMLTest_Valid_Table_WithPound(t *testing.T) {
2714 input := "[\"key#group\"]\nanswer = 42\n"
2715 jsonRef := "{\n \"key#group\": {\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n }\n}\n"
2716 testgenValid(t, input, jsonRef)
2717 }
2718
2719 func TestTOMLTest_Valid_Table_WithSingleQuotes(t *testing.T) {
2720 input := "['a']\n[a.'b']\n[a.'b'.c]\nanswer = 42 \n"
2721 jsonRef := "{\n \"a\": {\n \"b\": {\n \"c\": {\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n }\n }\n }\n}\n"
2722 testgenValid(t, input, jsonRef)
2723 }
2724
2725 func TestTOMLTest_Valid_Table_WithoutSuper(t *testing.T) {
2726 input := "# [x] you\n# [x.y] don't\n# [x.y.z] need these\n[x.y.z.w] # for this to work\n[x] # defining a super-table afterwards is ok\n"
2727 jsonRef := "{\n \"x\": {\n \"y\": {\n \"z\": {\n \"w\": {}\n }\n }\n }\n}\n"
2728 testgenValid(t, input, jsonRef)
2729 }
2730
View as plain text