1// Generated by tomltestgen for toml-test ref 39e37e6 on 2019-03-19T23:58:45-07:00
2package toml
3
4import (
5	"testing"
6)
7
8func TestInvalidArrayMixedTypesArraysAndInts(t *testing.T) {
9	input := `arrays-and-ints =  [1, ["Arrays are not integers."]]`
10	testgenInvalid(t, input)
11}
12
13func TestInvalidArrayMixedTypesIntsAndFloats(t *testing.T) {
14	input := `ints-and-floats = [1, 1.1]`
15	testgenInvalid(t, input)
16}
17
18func TestInvalidArrayMixedTypesStringsAndInts(t *testing.T) {
19	input := `strings-and-ints = ["hi", 42]`
20	testgenInvalid(t, input)
21}
22
23func TestInvalidDatetimeMalformedNoLeads(t *testing.T) {
24	input := `no-leads = 1987-7-05T17:45:00Z`
25	testgenInvalid(t, input)
26}
27
28func TestInvalidDatetimeMalformedNoSecs(t *testing.T) {
29	input := `no-secs = 1987-07-05T17:45Z`
30	testgenInvalid(t, input)
31}
32
33func TestInvalidDatetimeMalformedNoT(t *testing.T) {
34	input := `no-t = 1987-07-0517:45:00Z`
35	testgenInvalid(t, input)
36}
37
38func TestInvalidDatetimeMalformedWithMilli(t *testing.T) {
39	input := `with-milli = 1987-07-5T17:45:00.12Z`
40	testgenInvalid(t, input)
41}
42
43func TestInvalidDuplicateKeyTable(t *testing.T) {
44	input := `[fruit]
45type = "apple"
46
47[fruit.type]
48apple = "yes"`
49	testgenInvalid(t, input)
50}
51
52func TestInvalidDuplicateKeys(t *testing.T) {
53	input := `dupe = false
54dupe = true`
55	testgenInvalid(t, input)
56}
57
58func TestInvalidDuplicateTables(t *testing.T) {
59	input := `[a]
60[a]`
61	testgenInvalid(t, input)
62}
63
64func TestInvalidEmptyImplicitTable(t *testing.T) {
65	input := `[naughty..naughty]`
66	testgenInvalid(t, input)
67}
68
69func TestInvalidEmptyTable(t *testing.T) {
70	input := `[]`
71	testgenInvalid(t, input)
72}
73
74func TestInvalidFloatNoLeadingZero(t *testing.T) {
75	input := `answer = .12345
76neganswer = -.12345`
77	testgenInvalid(t, input)
78}
79
80func TestInvalidFloatNoTrailingDigits(t *testing.T) {
81	input := `answer = 1.
82neganswer = -1.`
83	testgenInvalid(t, input)
84}
85
86func TestInvalidKeyEmpty(t *testing.T) {
87	input := ` = 1`
88	testgenInvalid(t, input)
89}
90
91func TestInvalidKeyHash(t *testing.T) {
92	input := `a# = 1`
93	testgenInvalid(t, input)
94}
95
96func TestInvalidKeyNewline(t *testing.T) {
97	input := `a
98= 1`
99	testgenInvalid(t, input)
100}
101
102func TestInvalidKeyOpenBracket(t *testing.T) {
103	input := `[abc = 1`
104	testgenInvalid(t, input)
105}
106
107func TestInvalidKeySingleOpenBracket(t *testing.T) {
108	input := `[`
109	testgenInvalid(t, input)
110}
111
112func TestInvalidKeySpace(t *testing.T) {
113	input := `a b = 1`
114	testgenInvalid(t, input)
115}
116
117func TestInvalidKeyStartBracket(t *testing.T) {
118	input := `[a]
119[xyz = 5
120[b]`
121	testgenInvalid(t, input)
122}
123
124func TestInvalidKeyTwoEquals(t *testing.T) {
125	input := `key= = 1`
126	testgenInvalid(t, input)
127}
128
129func TestInvalidStringBadByteEscape(t *testing.T) {
130	input := `naughty = "\xAg"`
131	testgenInvalid(t, input)
132}
133
134func TestInvalidStringBadEscape(t *testing.T) {
135	input := `invalid-escape = "This string has a bad \a escape character."`
136	testgenInvalid(t, input)
137}
138
139func TestInvalidStringByteEscapes(t *testing.T) {
140	input := `answer = "\x33"`
141	testgenInvalid(t, input)
142}
143
144func TestInvalidStringNoClose(t *testing.T) {
145	input := `no-ending-quote = "One time, at band camp`
146	testgenInvalid(t, input)
147}
148
149func TestInvalidTableArrayImplicit(t *testing.T) {
150	input := "# This test is a bit tricky. It should fail because the first use of\n" +
151		"# `[[albums.songs]]` without first declaring `albums` implies that `albums`\n" +
152		"# must be a table. The alternative would be quite weird. Namely, it wouldn't\n" +
153		"# comply with the TOML spec: \"Each double-bracketed sub-table will belong to \n" +
154		"# the most *recently* defined table element *above* it.\"\n" +
155		"#\n" +
156		"# This is in contrast to the *valid* test, table-array-implicit where\n" +
157		"# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared\n" +
158		"# later. (Although, `[albums]` could be.)\n" +
159		"[[albums.songs]]\n" +
160		"name = \"Glory Days\"\n" +
161		"\n" +
162		"[[albums]]\n" +
163		"name = \"Born in the USA\"\n"
164	testgenInvalid(t, input)
165}
166
167func TestInvalidTableArrayMalformedBracket(t *testing.T) {
168	input := `[[albums]
169name = "Born to Run"`
170	testgenInvalid(t, input)
171}
172
173func TestInvalidTableArrayMalformedEmpty(t *testing.T) {
174	input := `[[]]
175name = "Born to Run"`
176	testgenInvalid(t, input)
177}
178
179func TestInvalidTableEmpty(t *testing.T) {
180	input := `[]`
181	testgenInvalid(t, input)
182}
183
184func TestInvalidTableNestedBracketsClose(t *testing.T) {
185	input := `[a]b]
186zyx = 42`
187	testgenInvalid(t, input)
188}
189
190func TestInvalidTableNestedBracketsOpen(t *testing.T) {
191	input := `[a[b]
192zyx = 42`
193	testgenInvalid(t, input)
194}
195
196func TestInvalidTableWhitespace(t *testing.T) {
197	input := `[invalid key]`
198	testgenInvalid(t, input)
199}
200
201func TestInvalidTableWithPound(t *testing.T) {
202	input := `[key#group]
203answer = 42`
204	testgenInvalid(t, input)
205}
206
207func TestInvalidTextAfterArrayEntries(t *testing.T) {
208	input := `array = [
209  "Is there life after an array separator?", No
210  "Entry"
211]`
212	testgenInvalid(t, input)
213}
214
215func TestInvalidTextAfterInteger(t *testing.T) {
216	input := `answer = 42 the ultimate answer?`
217	testgenInvalid(t, input)
218}
219
220func TestInvalidTextAfterString(t *testing.T) {
221	input := `string = "Is there life after strings?" No.`
222	testgenInvalid(t, input)
223}
224
225func TestInvalidTextAfterTable(t *testing.T) {
226	input := `[error] this shouldn't be here`
227	testgenInvalid(t, input)
228}
229
230func TestInvalidTextBeforeArraySeparator(t *testing.T) {
231	input := `array = [
232  "Is there life before an array separator?" No,
233  "Entry"
234]`
235	testgenInvalid(t, input)
236}
237
238func TestInvalidTextInArray(t *testing.T) {
239	input := `array = [
240  "Entry 1",
241  I don't belong,
242  "Entry 2",
243]`
244	testgenInvalid(t, input)
245}
246
247func TestValidArrayEmpty(t *testing.T) {
248	input := `thevoid = [[[[[]]]]]`
249	jsonRef := `{
250    "thevoid": { "type": "array", "value": [
251        {"type": "array", "value": [
252            {"type": "array", "value": [
253                {"type": "array", "value": [
254                    {"type": "array", "value": []}
255                ]}
256            ]}
257        ]}
258    ]}
259}`
260	testgenValid(t, input, jsonRef)
261}
262
263func TestValidArrayNospaces(t *testing.T) {
264	input := `ints = [1,2,3]`
265	jsonRef := `{
266    "ints": {
267        "type": "array",
268        "value": [
269            {"type": "integer", "value": "1"},
270            {"type": "integer", "value": "2"},
271            {"type": "integer", "value": "3"}
272        ]
273    }
274}`
275	testgenValid(t, input, jsonRef)
276}
277
278func TestValidArraysHetergeneous(t *testing.T) {
279	input := `mixed = [[1, 2], ["a", "b"], [1.1, 2.1]]`
280	jsonRef := `{
281    "mixed": {
282        "type": "array",
283        "value": [
284            {"type": "array", "value": [
285                {"type": "integer", "value": "1"},
286                {"type": "integer", "value": "2"}
287            ]},
288            {"type": "array", "value": [
289                {"type": "string", "value": "a"},
290                {"type": "string", "value": "b"}
291            ]},
292            {"type": "array", "value": [
293                {"type": "float", "value": "1.1"},
294                {"type": "float", "value": "2.1"}
295            ]}
296        ]
297    }
298}`
299	testgenValid(t, input, jsonRef)
300}
301
302func TestValidArraysNested(t *testing.T) {
303	input := `nest = [["a"], ["b"]]`
304	jsonRef := `{
305    "nest": {
306        "type": "array",
307        "value": [
308            {"type": "array", "value": [
309                {"type": "string", "value": "a"}
310            ]},
311            {"type": "array", "value": [
312                {"type": "string", "value": "b"}
313            ]}
314        ]
315    }
316}`
317	testgenValid(t, input, jsonRef)
318}
319
320func TestValidArrays(t *testing.T) {
321	input := `ints = [1, 2, 3]
322floats = [1.1, 2.1, 3.1]
323strings = ["a", "b", "c"]
324dates = [
325  1987-07-05T17:45:00Z,
326  1979-05-27T07:32:00Z,
327  2006-06-01T11:00:00Z,
328]`
329	jsonRef := `{
330    "ints": {
331        "type": "array",
332        "value": [
333            {"type": "integer", "value": "1"},
334            {"type": "integer", "value": "2"},
335            {"type": "integer", "value": "3"}
336        ]
337    },
338    "floats": {
339        "type": "array",
340        "value": [
341            {"type": "float", "value": "1.1"},
342            {"type": "float", "value": "2.1"},
343            {"type": "float", "value": "3.1"}
344        ]
345    },
346    "strings": {
347        "type": "array",
348        "value": [
349            {"type": "string", "value": "a"},
350            {"type": "string", "value": "b"},
351            {"type": "string", "value": "c"}
352        ]
353    },
354    "dates": {
355        "type": "array",
356        "value": [
357            {"type": "datetime", "value": "1987-07-05T17:45:00Z"},
358            {"type": "datetime", "value": "1979-05-27T07:32:00Z"},
359            {"type": "datetime", "value": "2006-06-01T11:00:00Z"}
360        ]
361    }
362}`
363	testgenValid(t, input, jsonRef)
364}
365
366func TestValidBool(t *testing.T) {
367	input := `t = true
368f = false`
369	jsonRef := `{
370    "f": {"type": "bool", "value": "false"},
371    "t": {"type": "bool", "value": "true"}
372}`
373	testgenValid(t, input, jsonRef)
374}
375
376func TestValidCommentsEverywhere(t *testing.T) {
377	input := `# Top comment.
378  # Top comment.
379# Top comment.
380
381# [no-extraneous-groups-please]
382
383[group] # Comment
384answer = 42 # Comment
385# no-extraneous-keys-please = 999
386# Inbetween comment.
387more = [ # Comment
388  # What about multiple # comments?
389  # Can you handle it?
390  #
391          # Evil.
392# Evil.
393  42, 42, # Comments within arrays are fun.
394  # What about multiple # comments?
395  # Can you handle it?
396  #
397          # Evil.
398# Evil.
399# ] Did I fool you?
400] # Hopefully not.`
401	jsonRef := `{
402    "group": {
403        "answer": {"type": "integer", "value": "42"},
404        "more": {
405            "type": "array",
406            "value": [
407                {"type": "integer", "value": "42"},
408                {"type": "integer", "value": "42"}
409            ]
410        }
411    }
412}`
413	testgenValid(t, input, jsonRef)
414}
415
416func TestValidDatetime(t *testing.T) {
417	input := `bestdayever = 1987-07-05T17:45:00Z`
418	jsonRef := `{
419    "bestdayever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"}
420}`
421	testgenValid(t, input, jsonRef)
422}
423
424func TestValidEmpty(t *testing.T) {
425	input := ``
426	jsonRef := `{}`
427	testgenValid(t, input, jsonRef)
428}
429
430func TestValidExample(t *testing.T) {
431	input := `best-day-ever = 1987-07-05T17:45:00Z
432
433[numtheory]
434boring = false
435perfection = [6, 28, 496]`
436	jsonRef := `{
437  "best-day-ever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"},
438  "numtheory": {
439    "boring": {"type": "bool", "value": "false"},
440    "perfection": {
441      "type": "array",
442      "value": [
443        {"type": "integer", "value": "6"},
444        {"type": "integer", "value": "28"},
445        {"type": "integer", "value": "496"}
446      ]
447    }
448  }
449}`
450	testgenValid(t, input, jsonRef)
451}
452
453func TestValidFloat(t *testing.T) {
454	input := `pi = 3.14
455negpi = -3.14`
456	jsonRef := `{
457    "pi": {"type": "float", "value": "3.14"},
458    "negpi": {"type": "float", "value": "-3.14"}
459}`
460	testgenValid(t, input, jsonRef)
461}
462
463func TestValidImplicitAndExplicitAfter(t *testing.T) {
464	input := `[a.b.c]
465answer = 42
466
467[a]
468better = 43`
469	jsonRef := `{
470    "a": {
471        "better": {"type": "integer", "value": "43"},
472        "b": {
473            "c": {
474                "answer": {"type": "integer", "value": "42"}
475            }
476        }
477    }
478}`
479	testgenValid(t, input, jsonRef)
480}
481
482func TestValidImplicitAndExplicitBefore(t *testing.T) {
483	input := `[a]
484better = 43
485
486[a.b.c]
487answer = 42`
488	jsonRef := `{
489    "a": {
490        "better": {"type": "integer", "value": "43"},
491        "b": {
492            "c": {
493                "answer": {"type": "integer", "value": "42"}
494            }
495        }
496    }
497}`
498	testgenValid(t, input, jsonRef)
499}
500
501func TestValidImplicitGroups(t *testing.T) {
502	input := `[a.b.c]
503answer = 42`
504	jsonRef := `{
505    "a": {
506        "b": {
507            "c": {
508                "answer": {"type": "integer", "value": "42"}
509            }
510        }
511    }
512}`
513	testgenValid(t, input, jsonRef)
514}
515
516func TestValidInteger(t *testing.T) {
517	input := `answer = 42
518neganswer = -42`
519	jsonRef := `{
520    "answer": {"type": "integer", "value": "42"},
521    "neganswer": {"type": "integer", "value": "-42"}
522}`
523	testgenValid(t, input, jsonRef)
524}
525
526func TestValidKeyEqualsNospace(t *testing.T) {
527	input := `answer=42`
528	jsonRef := `{
529    "answer": {"type": "integer", "value": "42"}
530}`
531	testgenValid(t, input, jsonRef)
532}
533
534func TestValidKeySpace(t *testing.T) {
535	input := `"a b" = 1`
536	jsonRef := `{
537    "a b": {"type": "integer", "value": "1"}
538}`
539	testgenValid(t, input, jsonRef)
540}
541
542func TestValidKeySpecialChars(t *testing.T) {
543	input := "\"~!@$^&*()_+-`1234567890[]|/?><.,;:'\" = 1\n"
544	jsonRef := "{\n" +
545		"    \"~!@$^&*()_+-`1234567890[]|/?><.,;:'\": {\n" +
546		"        \"type\": \"integer\", \"value\": \"1\"\n" +
547		"    }\n" +
548		"}\n"
549	testgenValid(t, input, jsonRef)
550}
551
552func TestValidLongFloat(t *testing.T) {
553	input := `longpi = 3.141592653589793
554neglongpi = -3.141592653589793`
555	jsonRef := `{
556    "longpi": {"type": "float", "value": "3.141592653589793"},
557    "neglongpi": {"type": "float", "value": "-3.141592653589793"}
558}`
559	testgenValid(t, input, jsonRef)
560}
561
562func TestValidLongInteger(t *testing.T) {
563	input := `answer = 9223372036854775807
564neganswer = -9223372036854775808`
565	jsonRef := `{
566    "answer": {"type": "integer", "value": "9223372036854775807"},
567    "neganswer": {"type": "integer", "value": "-9223372036854775808"}
568}`
569	testgenValid(t, input, jsonRef)
570}
571
572func TestValidMultilineString(t *testing.T) {
573	input := `multiline_empty_one = """"""
574multiline_empty_two = """
575"""
576multiline_empty_three = """\
577    """
578multiline_empty_four = """\
579   \
580   \
581   """
582
583equivalent_one = "The quick brown fox jumps over the lazy dog."
584equivalent_two = """
585The quick brown \
586
587
588  fox jumps over \
589    the lazy dog."""
590
591equivalent_three = """\
592       The quick brown \
593       fox jumps over \
594       the lazy dog.\
595       """`
596	jsonRef := `{
597    "multiline_empty_one": {
598        "type": "string",
599        "value": ""
600    },
601    "multiline_empty_two": {
602        "type": "string",
603        "value": ""
604    },
605    "multiline_empty_three": {
606        "type": "string",
607        "value": ""
608    },
609    "multiline_empty_four": {
610        "type": "string",
611        "value": ""
612    },
613    "equivalent_one": {
614        "type": "string",
615        "value": "The quick brown fox jumps over the lazy dog."
616    },
617    "equivalent_two": {
618        "type": "string",
619        "value": "The quick brown fox jumps over the lazy dog."
620    },
621    "equivalent_three": {
622        "type": "string",
623        "value": "The quick brown fox jumps over the lazy dog."
624    }
625}`
626	testgenValid(t, input, jsonRef)
627}
628
629func TestValidRawMultilineString(t *testing.T) {
630	input := `oneline = '''This string has a ' quote character.'''
631firstnl = '''
632This string has a ' quote character.'''
633multiline = '''
634This string
635has ' a quote character
636and more than
637one newline
638in it.'''`
639	jsonRef := `{
640    "oneline": {
641        "type": "string",
642        "value": "This string has a ' quote character."
643    },
644    "firstnl": {
645        "type": "string",
646        "value": "This string has a ' quote character."
647    },
648    "multiline": {
649        "type": "string",
650        "value": "This string\nhas ' a quote character\nand more than\none newline\nin it."
651    }
652}`
653	testgenValid(t, input, jsonRef)
654}
655
656func TestValidRawString(t *testing.T) {
657	input := `backspace = 'This string has a \b backspace character.'
658tab = 'This string has a \t tab character.'
659newline = 'This string has a \n new line character.'
660formfeed = 'This string has a \f form feed character.'
661carriage = 'This string has a \r carriage return character.'
662slash = 'This string has a \/ slash character.'
663backslash = 'This string has a \\ backslash character.'`
664	jsonRef := `{
665    "backspace": {
666        "type": "string",
667        "value": "This string has a \\b backspace character."
668    },
669    "tab": {
670        "type": "string",
671        "value": "This string has a \\t tab character."
672    },
673    "newline": {
674        "type": "string",
675        "value": "This string has a \\n new line character."
676    },
677    "formfeed": {
678        "type": "string",
679        "value": "This string has a \\f form feed character."
680    },
681    "carriage": {
682        "type": "string",
683        "value": "This string has a \\r carriage return character."
684    },
685    "slash": {
686        "type": "string",
687        "value": "This string has a \\/ slash character."
688    },
689    "backslash": {
690        "type": "string",
691        "value": "This string has a \\\\ backslash character."
692    }
693}`
694	testgenValid(t, input, jsonRef)
695}
696
697func TestValidStringEmpty(t *testing.T) {
698	input := `answer = ""`
699	jsonRef := `{
700    "answer": {
701        "type": "string",
702        "value": ""
703    }
704}`
705	testgenValid(t, input, jsonRef)
706}
707
708func TestValidStringEscapes(t *testing.T) {
709	input := `backspace = "This string has a \b backspace character."
710tab = "This string has a \t tab character."
711newline = "This string has a \n new line character."
712formfeed = "This string has a \f form feed character."
713carriage = "This string has a \r carriage return character."
714quote = "This string has a \" quote character."
715backslash = "This string has a \\ backslash character."
716notunicode1 = "This string does not have a unicode \\u escape."
717notunicode2 = "This string does not have a unicode \u005Cu escape."
718notunicode3 = "This string does not have a unicode \\u0075 escape."
719notunicode4 = "This string does not have a unicode \\\u0075 escape."`
720	jsonRef := `{
721    "backspace": {
722        "type": "string",
723        "value": "This string has a \u0008 backspace character."
724    },
725    "tab": {
726        "type": "string",
727        "value": "This string has a \u0009 tab character."
728    },
729    "newline": {
730        "type": "string",
731        "value": "This string has a \u000A new line character."
732    },
733    "formfeed": {
734        "type": "string",
735        "value": "This string has a \u000C form feed character."
736    },
737    "carriage": {
738        "type": "string",
739        "value": "This string has a \u000D carriage return character."
740    },
741    "quote": {
742        "type": "string",
743        "value": "This string has a \u0022 quote character."
744    },
745    "backslash": {
746        "type": "string",
747        "value": "This string has a \u005C backslash character."
748    },
749    "notunicode1": {
750        "type": "string",
751        "value": "This string does not have a unicode \\u escape."
752    },
753    "notunicode2": {
754        "type": "string",
755        "value": "This string does not have a unicode \u005Cu escape."
756    },
757    "notunicode3": {
758        "type": "string",
759        "value": "This string does not have a unicode \\u0075 escape."
760    },
761    "notunicode4": {
762        "type": "string",
763        "value": "This string does not have a unicode \\\u0075 escape."
764    }
765}`
766	testgenValid(t, input, jsonRef)
767}
768
769func TestValidStringSimple(t *testing.T) {
770	input := `answer = "You are not drinking enough whisky."`
771	jsonRef := `{
772    "answer": {
773        "type": "string",
774        "value": "You are not drinking enough whisky."
775    }
776}`
777	testgenValid(t, input, jsonRef)
778}
779
780func TestValidStringWithPound(t *testing.T) {
781	input := `pound = "We see no # comments here."
782poundcomment = "But there are # some comments here." # Did I # mess you up?`
783	jsonRef := `{
784    "pound": {"type": "string", "value": "We see no # comments here."},
785    "poundcomment": {
786        "type": "string",
787        "value": "But there are # some comments here."
788    }
789}`
790	testgenValid(t, input, jsonRef)
791}
792
793func TestValidTableArrayImplicit(t *testing.T) {
794	input := `[[albums.songs]]
795name = "Glory Days"`
796	jsonRef := `{
797    "albums": {
798       "songs": [
799           {"name": {"type": "string", "value": "Glory Days"}}
800       ]
801    }
802}`
803	testgenValid(t, input, jsonRef)
804}
805
806func TestValidTableArrayMany(t *testing.T) {
807	input := `[[people]]
808first_name = "Bruce"
809last_name = "Springsteen"
810
811[[people]]
812first_name = "Eric"
813last_name = "Clapton"
814
815[[people]]
816first_name = "Bob"
817last_name = "Seger"`
818	jsonRef := `{
819    "people": [
820        {
821            "first_name": {"type": "string", "value": "Bruce"},
822            "last_name": {"type": "string", "value": "Springsteen"}
823        },
824        {
825            "first_name": {"type": "string", "value": "Eric"},
826            "last_name": {"type": "string", "value": "Clapton"}
827        },
828        {
829            "first_name": {"type": "string", "value": "Bob"},
830            "last_name": {"type": "string", "value": "Seger"}
831        }
832    ]
833}`
834	testgenValid(t, input, jsonRef)
835}
836
837func TestValidTableArrayNest(t *testing.T) {
838	input := `[[albums]]
839name = "Born to Run"
840
841  [[albums.songs]]
842  name = "Jungleland"
843
844  [[albums.songs]]
845  name = "Meeting Across the River"
846
847[[albums]]
848name = "Born in the USA"
849
850  [[albums.songs]]
851  name = "Glory Days"
852
853  [[albums.songs]]
854  name = "Dancing in the Dark"`
855	jsonRef := `{
856    "albums": [
857        {
858            "name": {"type": "string", "value": "Born to Run"},
859            "songs": [
860                {"name": {"type": "string", "value": "Jungleland"}},
861                {"name": {"type": "string", "value": "Meeting Across the River"}}
862            ]
863        },
864        {
865            "name": {"type": "string", "value": "Born in the USA"},
866            "songs": [
867                {"name": {"type": "string", "value": "Glory Days"}},
868                {"name": {"type": "string", "value": "Dancing in the Dark"}}
869            ]
870        }
871    ]
872}`
873	testgenValid(t, input, jsonRef)
874}
875
876func TestValidTableArrayOne(t *testing.T) {
877	input := `[[people]]
878first_name = "Bruce"
879last_name = "Springsteen"`
880	jsonRef := `{
881    "people": [
882        {
883            "first_name": {"type": "string", "value": "Bruce"},
884            "last_name": {"type": "string", "value": "Springsteen"}
885        }
886    ]
887}`
888	testgenValid(t, input, jsonRef)
889}
890
891func TestValidTableEmpty(t *testing.T) {
892	input := `[a]`
893	jsonRef := `{
894    "a": {}
895}`
896	testgenValid(t, input, jsonRef)
897}
898
899func TestValidTableSubEmpty(t *testing.T) {
900	input := `[a]
901[a.b]`
902	jsonRef := `{
903    "a": { "b": {} }
904}`
905	testgenValid(t, input, jsonRef)
906}
907
908func TestValidTableWhitespace(t *testing.T) {
909	input := `["valid key"]`
910	jsonRef := `{
911    "valid key": {}
912}`
913	testgenValid(t, input, jsonRef)
914}
915
916func TestValidTableWithPound(t *testing.T) {
917	input := `["key#group"]
918answer = 42`
919	jsonRef := `{
920    "key#group": {
921        "answer": {"type": "integer", "value": "42"}
922    }
923}`
924	testgenValid(t, input, jsonRef)
925}
926
927func TestValidUnicodeEscape(t *testing.T) {
928	input := `answer4 = "\u03B4"
929answer8 = "\U000003B4"`
930	jsonRef := `{
931    "answer4": {"type": "string", "value": "\u03B4"},
932    "answer8": {"type": "string", "value": "\u03B4"}
933}`
934	testgenValid(t, input, jsonRef)
935}
936
937func TestValidUnicodeLiteral(t *testing.T) {
938	input := `answer = "δ"`
939	jsonRef := `{
940    "answer": {"type": "string", "value": "δ"}
941}`
942	testgenValid(t, input, jsonRef)
943}
944