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