forked from pelletier/go-toml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toml_testgen_test.go
1716 lines (1393 loc) · 97.3 KB
/
toml_testgen_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Generated by tomltestgen for toml-test ref master on 2022-04-07T20:09:42-04:00
package toml_test
import (
"testing"
)
func TestTOMLTest_Invalid_Array_MissingSeparator(t *testing.T) {
input := "wrong = [ 1 2 3 ]\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_NoClose2(t *testing.T) {
input := "x = [42 #\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_NoCloseTable2(t *testing.T) {
input := "x = [{ key = 42 #\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_NoCloseTable(t *testing.T) {
input := "x = [{ key = 42\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_NoClose(t *testing.T) {
input := "long_array = [ 1, 2, 3\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_Tables1(t *testing.T) {
input := "# INVALID TOML DOC\nfruit = []\n\n[[fruit]] # Not allowed\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_Tables2(t *testing.T) {
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"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_TextAfterArrayEntries(t *testing.T) {
input := "array = [\n \"Is there life after an array separator?\", No\n \"Entry\"\n]\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_TextBeforeArraySeparator(t *testing.T) {
input := "array = [\n \"Is there life before an array separator?\" No,\n \"Entry\"\n]\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Array_TextInArray(t *testing.T) {
input := "array = [\n \"Entry 1\",\n I don't belong,\n \"Entry 2\",\n]\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_AlmostFalseWithExtra(t *testing.T) {
input := "a = falsify\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_AlmostFalse(t *testing.T) {
input := "a = fals\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_AlmostTrueWithExtra(t *testing.T) {
input := "a = truthy\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_AlmostTrue(t *testing.T) {
input := "a = tru\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_JustF(t *testing.T) {
input := "a = f\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_JustT(t *testing.T) {
input := "a = t\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_MixedCase(t *testing.T) {
input := "valid = False\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_StartingSameFalse(t *testing.T) {
input := "a = falsey\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_StartingSameTrue(t *testing.T) {
input := "a = truer\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_WrongCaseFalse(t *testing.T) {
input := "b = FALSE\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Bool_WrongCaseTrue(t *testing.T) {
input := "a = TRUE\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_BareCr(t *testing.T) {
input := "# The following line contains a single carriage return control character\r\n\r"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_BareFormfeed(t *testing.T) {
input := "bare-formfeed = \f\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_BareNull(t *testing.T) {
input := "bare-null = \"some value\" \x00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_BareVerticalTab(t *testing.T) {
input := "bare-vertical-tab = \v\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_CommentCr(t *testing.T) {
input := "comment-cr = \"Carriage return in comment\" # \ra=1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_CommentDel(t *testing.T) {
input := "comment-del = \"0x7f\" # \u007f\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_CommentLf(t *testing.T) {
input := "comment-lf = \"ctrl-P\" # \x10\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_CommentNull(t *testing.T) {
input := "comment-null = \"null\" # \x00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_CommentUs(t *testing.T) {
input := "comment-us = \"ctrl-_\" # \x1f\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_MultiDel(t *testing.T) {
input := "multi-del = \"\"\"null\u007f\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_MultiLf(t *testing.T) {
input := "multi-lf = \"\"\"null\x10\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_MultiNull(t *testing.T) {
input := "multi-null = \"\"\"null\x00\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_MultiUs(t *testing.T) {
input := "multi-us = \"\"\"null\x1f\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawmultiDel(t *testing.T) {
input := "rawmulti-del = '''null\u007f'''\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawmultiLf(t *testing.T) {
input := "rawmulti-lf = '''null\x10'''\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawmultiNull(t *testing.T) {
input := "rawmulti-null = '''null\x00'''\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawmultiUs(t *testing.T) {
input := "rawmulti-us = '''null\x1f'''\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawstringDel(t *testing.T) {
input := "rawstring-del = 'null\u007f'\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawstringLf(t *testing.T) {
input := "rawstring-lf = 'null\x10'\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawstringNull(t *testing.T) {
input := "rawstring-null = 'null\x00'\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_RawstringUs(t *testing.T) {
input := "rawstring-us = 'null\x1f'\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_StringBs(t *testing.T) {
input := "string-bs = \"backspace\b\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_StringDel(t *testing.T) {
input := "string-del = \"null\u007f\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_StringLf(t *testing.T) {
input := "string-lf = \"null\x10\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_StringNull(t *testing.T) {
input := "string-null = \"null\x00\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Control_StringUs(t *testing.T) {
input := "string-us = \"null\x1f\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_HourOver(t *testing.T) {
input := "# time-hour = 2DIGIT ; 00-23\nd = 2006-01-01T24:00:00-00:00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_MdayOver(t *testing.T) {
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"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_MdayUnder(t *testing.T) {
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"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_MinuteOver(t *testing.T) {
input := "# time-minute = 2DIGIT ; 00-59\nd = 2006-01-01T00:60:00-00:00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_MonthOver(t *testing.T) {
input := "# date-month = 2DIGIT ; 01-12\nd = 2006-13-01T00:00:00-00:00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_MonthUnder(t *testing.T) {
input := "# date-month = 2DIGIT ; 01-12\nd = 2007-00-01T00:00:00-00:00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_NoLeadsWithMilli(t *testing.T) {
input := "# Day \"5\" instead of \"05\"; the leading zero is required.\nwith-milli = 1987-07-5T17:45:00.12Z\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_NoLeads(t *testing.T) {
input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05T17:45:00Z\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_NoSecs(t *testing.T) {
input := "# No seconds in time.\nno-secs = 1987-07-05T17:45Z\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_NoT(t *testing.T) {
input := "# No \"t\" or \"T\" between the date and time.\nno-t = 1987-07-0517:45:00Z\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_SecondOver(t *testing.T) {
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"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_TimeNoLeads2(t *testing.T) {
input := "# Leading 0 is always required.\nd = 01:32:0\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_TimeNoLeads(t *testing.T) {
input := "# Leading 0 is always required.\nd = 1:32:00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Datetime_TrailingT(t *testing.T) {
input := "# Date cannot end with trailing T\nd = 2006-01-30T\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_BadUtf8AtEnd(t *testing.T) {
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"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_BadUtf8InComment(t *testing.T) {
input := "# \xc3\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_BadUtf8InString(t *testing.T) {
input := "# The following line contains an invalid UTF-8 sequence.\nbad = \"\xc3\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_BomNotAtStart1(t *testing.T) {
input := "bom-not-at-start \xff\xfd\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_BomNotAtStart2(t *testing.T) {
input := "bom-not-at-start= \xff\xfd\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_Utf16Bom(t *testing.T) {
input := "\xfe\xff\x00#\x00 \x00U\x00T\x00F\x00-\x001\x006\x00 \x00w\x00i\x00t\x00h\x00 \x00B\x00O\x00M\x00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Encoding_Utf16(t *testing.T) {
input := "\x00#\x00 \x00U\x00T\x00F\x00-\x001\x006\x00 \x00w\x00i\x00t\x00h\x00o\x00u\x00t\x00 \x00B\x00O\x00M\x00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_DoublePoint1(t *testing.T) {
input := "double-point-1 = 0..1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_DoublePoint2(t *testing.T) {
input := "double-point-2 = 0.1.2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpDoubleE1(t *testing.T) {
input := "exp-double-e-1 = 1ee2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpDoubleE2(t *testing.T) {
input := "exp-double-e-2 = 1e2e3\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpDoubleUs(t *testing.T) {
input := "exp-double-us = 1e__23\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpLeadingUs(t *testing.T) {
input := "exp-leading-us = 1e_23\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpPoint1(t *testing.T) {
input := "exp-point-1 = 1e2.3\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpPoint2(t *testing.T) {
input := "exp-point-2 = 1.e2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_ExpTrailingUs(t *testing.T) {
input := "exp-trailing-us = 1e_23_\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_InfIncomplete1(t *testing.T) {
input := "inf-incomplete-1 = in\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_InfIncomplete2(t *testing.T) {
input := "inf-incomplete-2 = +in\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_InfIncomplete3(t *testing.T) {
input := "inf-incomplete-3 = -in\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_Inf_underscore(t *testing.T) {
input := "inf_underscore = in_f\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingPointNeg(t *testing.T) {
input := "leading-point-neg = -.12345\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingPointPlus(t *testing.T) {
input := "leading-point-plus = +.12345\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingPoint(t *testing.T) {
input := "leading-point = .12345\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingUs(t *testing.T) {
input := "leading-us = _1.2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingZeroNeg(t *testing.T) {
input := "leading-zero-neg = -03.14\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingZeroPlus(t *testing.T) {
input := "leading-zero-plus = +03.14\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_LeadingZero(t *testing.T) {
input := "leading-zero = 03.14\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_NanIncomplete1(t *testing.T) {
input := "nan-incomplete-1 = na\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_NanIncomplete2(t *testing.T) {
input := "nan-incomplete-2 = +na\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_NanIncomplete3(t *testing.T) {
input := "nan-incomplete-3 = -na\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_Nan_underscore(t *testing.T) {
input := "nan_underscore = na_n\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_TrailingPointMin(t *testing.T) {
input := "trailing-point-min = -1.\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_TrailingPointPlus(t *testing.T) {
input := "trailing-point-plus = +1.\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_TrailingPoint(t *testing.T) {
input := "trailing-point = 1.\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_TrailingUsExp(t *testing.T) {
input := "# trailing underscore in integer part is not allowed\ntrailing-us-exp = 1_e2\n# trailing underscore in float part is not allowed\ntrailing-us-exp2 = 1.2_e2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_TrailingUs(t *testing.T) {
input := "trailing-us = 1.2_\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_UsAfterPoint(t *testing.T) {
input := "us-after-point = 1._2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Float_UsBeforePoint(t *testing.T) {
input := "us-before-point = 1_.2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Add(t *testing.T) {
input := "a={}\n# Inline tables are immutable and can't be extended\n[a.b]\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_DoubleComma(t *testing.T) {
input := "t = {x=3,,y=4}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_DuplicateKey(t *testing.T) {
input := "# Duplicate keys within an inline table are invalid\na={b=1, b=2}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Empty(t *testing.T) {
input := "t = {,}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Linebreak1(t *testing.T) {
input := "# No newlines are allowed between the curly braces unless they are valid within\n# a value.\nsimple = { a = 1 \n}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Linebreak2(t *testing.T) {
input := "t = {a=1,\nb=2}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Linebreak3(t *testing.T) {
input := "t = {a=1\n,b=2}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Linebreak4(t *testing.T) {
input := "json_like = {\n first = \"Tom\",\n last = \"Preston-Werner\"\n}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_NoComma(t *testing.T) {
input := "t = {x = 3 y = 4}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_Overwrite(t *testing.T) {
input := "a.b=0\n# Since table \"a\" is already defined, it can't be replaced by an inline table.\na={}\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_InlineTable_TrailingComma(t *testing.T) {
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"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_CapitalBin(t *testing.T) {
input := "capital-bin = 0B0\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_CapitalHex(t *testing.T) {
input := "capital-hex = 0X1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_CapitalOct(t *testing.T) {
input := "capital-oct = 0O0\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_DoubleSignNex(t *testing.T) {
input := "double-sign-nex = --99\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_DoubleSignPlus(t *testing.T) {
input := "double-sign-plus = ++99\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_DoubleUs(t *testing.T) {
input := "double-us = 1__23\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_IncompleteBin(t *testing.T) {
input := "incomplete-bin = 0b\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_IncompleteHex(t *testing.T) {
input := "incomplete-hex = 0x\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_IncompleteOct(t *testing.T) {
input := "incomplete-oct = 0o\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_InvalidBin(t *testing.T) {
input := "invalid-bin = 0b0012\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_InvalidHex(t *testing.T) {
input := "invalid-hex = 0xaafz\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_InvalidOct(t *testing.T) {
input := "invalid-oct = 0o778\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingUsBin(t *testing.T) {
input := "leading-us-bin = _0o1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingUsHex(t *testing.T) {
input := "leading-us-hex = _0o1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingUsOct(t *testing.T) {
input := "leading-us-oct = _0o1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingUs(t *testing.T) {
input := "leading-us = _123\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingZero1(t *testing.T) {
input := "leading-zero-1 = 01\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingZero2(t *testing.T) {
input := "leading-zero-2 = 00\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingZero3(t *testing.T) {
input := "leading-zero-3 = 0_0\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingZeroSign1(t *testing.T) {
input := "leading-zero-sign-1 = -01\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingZeroSign2(t *testing.T) {
input := "leading-zero-sign-2 = +01\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_LeadingZeroSign3(t *testing.T) {
input := "leading-zero-sign-3 = +0_1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_NegativeBin(t *testing.T) {
input := "negative-bin = -0b11010110\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_NegativeHex(t *testing.T) {
input := "negative-hex = -0xff\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_NegativeOct(t *testing.T) {
input := "negative-oct = -0o99\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_PositiveBin(t *testing.T) {
input := "positive-bin = +0b11010110\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_PositiveHex(t *testing.T) {
input := "positive-hex = +0xff\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_PositiveOct(t *testing.T) {
input := "positive-oct = +0o99\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_TextAfterInteger(t *testing.T) {
input := "answer = 42 the ultimate answer?\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_TrailingUsBin(t *testing.T) {
input := "trailing-us-bin = 0b1_\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_TrailingUsHex(t *testing.T) {
input := "trailing-us-hex = 0x1_\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_TrailingUsOct(t *testing.T) {
input := "trailing-us-oct = 0o1_\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_TrailingUs(t *testing.T) {
input := "trailing-us = 123_\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_UsAfterBin(t *testing.T) {
input := "us-after-bin = 0b_1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_UsAfterHex(t *testing.T) {
input := "us-after-hex = 0x_1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Integer_UsAfterOct(t *testing.T) {
input := "us-after-oct = 0o_1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_AfterArray(t *testing.T) {
input := "[[agencies]] owner = \"S Cjelli\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_AfterTable(t *testing.T) {
input := "[error] this = \"should not be here\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_AfterValue(t *testing.T) {
input := "first = \"Tom\" last = \"Preston-Werner\" # INVALID\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_BareInvalidCharacter(t *testing.T) {
input := "bare!key = 123\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_DottedRedefineTable(t *testing.T) {
input := "# Defined a.b as int\na.b = 1\n# Tries to access it as table: error\na.b.c = 2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_DuplicateKeys(t *testing.T) {
input := "dupe = false\ndupe = true\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Duplicate(t *testing.T) {
input := "# DO NOT DO THIS\nname = \"Tom\"\nname = \"Pradyun\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Empty(t *testing.T) {
input := " = 1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Escape(t *testing.T) {
input := "\\u00c0 = \"latin capital letter A with grave\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Hash(t *testing.T) {
input := "a# = 1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Multiline(t *testing.T) {
input := "\"\"\"long\nkey\"\"\" = 1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Newline(t *testing.T) {
input := "barekey\n = 123\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_NoEol(t *testing.T) {
input := "a = 1 b = 2\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_OpenBracket(t *testing.T) {
input := "[abc = 1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_PartialQuoted(t *testing.T) {
input := "partial\"quoted\" = 5\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_SingleOpenBracket(t *testing.T) {
input := "[\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_Space(t *testing.T) {
input := "a b = 1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_SpecialCharacter(t *testing.T) {
input := "μ = \"greek small letter mu\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_StartBracket(t *testing.T) {
input := "[a]\n[xyz = 5\n[b]\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_TwoEquals(t *testing.T) {
input := "key= = 1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_TwoEquals2(t *testing.T) {
input := "a==1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_TwoEquals3(t *testing.T) {
input := "a=b=1\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_WithoutValue1(t *testing.T) {
input := "key\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_Key_WithoutValue2(t *testing.T) {
input := "key = \n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadByteEscape(t *testing.T) {
input := "naughty = \"\\xAg\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadCodepoint(t *testing.T) {
input := "invalid-codepoint = \"This string contains a non scalar unicode codepoint \\uD801\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadConcat(t *testing.T) {
input := "no_concat = \"first\" \"second\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadEscape1(t *testing.T) {
input := "invalid-escape = \"This string has a bad \\a escape character.\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadEscape2(t *testing.T) {
input := "invalid-escape = \"This string has a bad \\ escape character.\"\n\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadMultiline(t *testing.T) {
input := "multi = \"first line\nsecond line\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadSlashEscape(t *testing.T) {
input := "invalid-escape = \"This string has a bad \\/ escape character.\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BadUniEsc(t *testing.T) {
input := "str = \"val\\ue\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicByteEscapes(t *testing.T) {
input := "answer = \"\\x33\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape1(t *testing.T) {
input := "a = \"\"\"\\UFFFFFFFF\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape2(t *testing.T) {
input := "a = \"\"\"\\U00D80000\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicMultilineQuotes(t *testing.T) {
input := "str5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicMultilineUnknownEscape(t *testing.T) {
input := "a = \"\"\"\\@\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicOutOfRangeUnicodeEscape1(t *testing.T) {
input := "a = \"\\UFFFFFFFF\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicOutOfRangeUnicodeEscape2(t *testing.T) {
input := "a = \"\\U00D80000\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_BasicUnknownEscape(t *testing.T) {
input := "a = \"\\@\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_LiteralMultilineQuotes1(t *testing.T) {
input := "a = '''6 apostrophes: ''''''\n\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_LiteralMultilineQuotes2(t *testing.T) {
input := "a = '''15 apostrophes: ''''''''''''''''''\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MissingQuotes(t *testing.T) {
input := "name = value\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineBadEscape1(t *testing.T) {
input := "k = \"\"\"t\\a\"\"\"\n\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineBadEscape2(t *testing.T) {
input := "# \\<Space> is not a valid escape.\nk = \"\"\"t\\ t\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineBadEscape3(t *testing.T) {
input := "# \\<Space> is not a valid escape.\nk = \"\"\"t\\ \"\"\"\n\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineEscapeSpace(t *testing.T) {
input := "a = \"\"\"\n foo \\ \\n\n bar\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineNoClose2(t *testing.T) {
input := "x=\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineNoClose(t *testing.T) {
input := "invalid = \"\"\"\n this will fail\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_MultilineQuotes1(t *testing.T) {
input := "a = \"\"\"6 quotes: \"\"\"\"\"\"\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_NoClose(t *testing.T) {
input := "no-ending-quote = \"One time, at band camp\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_TextAfterString(t *testing.T) {
input := "string = \"Is there life after strings?\" No.\n"
testgenInvalid(t, input)
}
func TestTOMLTest_Invalid_String_WrongClose(t *testing.T) {
input := "bad-ending-quote = \"double and single'\n"
testgenInvalid(t, input)