Update and move testsuite to internal package (#730)
* Regenerate test suite * Move test suite to /internal
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/pelletier/go-toml/v2/testsuite"
|
"github.com/pelletier/go-toml/v2/internal/testsuite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/pelletier/go-toml/v2"
|
"github.com/pelletier/go-toml/v2"
|
||||||
"github.com/pelletier/go-toml/v2/testsuite"
|
"github.com/pelletier/go-toml/v2/internal/testsuite"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+126
-25
@@ -1,4 +1,4 @@
|
|||||||
// Generated by tomltestgen for toml-test ref master on 2021-11-08T22:33:24-05:00
|
// Generated by tomltestgen for toml-test ref master on 2021-12-31T17:10:15-05:00
|
||||||
package toml_test
|
package toml_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -70,6 +70,16 @@ func TestTOMLTest_Invalid_Bool_WrongCaseTrue(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
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_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) {
|
func TestTOMLTest_Invalid_Control_CommentDel(t *testing.T) {
|
||||||
input := "comment-del = \"0x7f\" # \u007f\n"
|
input := "comment-del = \"0x7f\" # \u007f\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -175,33 +185,73 @@ func TestTOMLTest_Invalid_Control_StringUs(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Datetime_ImpossibleDate(t *testing.T) {
|
func TestTOMLTest_Invalid_Datetime_HourOver(t *testing.T) {
|
||||||
input := "d = 2006-01-50T00:00:00Z\n"
|
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)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Datetime_NoLeadsWithMilli(t *testing.T) {
|
func TestTOMLTest_Invalid_Datetime_NoLeadsWithMilli(t *testing.T) {
|
||||||
input := "with-milli = 1987-07-5T17:45:00.12Z\n"
|
input := "# Day \"5\" instead of \"05\"; the leading zero is required.\nwith-milli = 1987-07-5T17:45:00.12Z\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Datetime_NoLeads(t *testing.T) {
|
func TestTOMLTest_Invalid_Datetime_NoLeads(t *testing.T) {
|
||||||
input := "no-leads = 1987-7-05T17:45:00Z\n"
|
input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05T17:45:00Z\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Datetime_NoSecs(t *testing.T) {
|
func TestTOMLTest_Invalid_Datetime_NoSecs(t *testing.T) {
|
||||||
input := "no-secs = 1987-07-05T17:45Z\n"
|
input := "# No seconds in time.\nno-secs = 1987-07-05T17:45Z\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Datetime_NoT(t *testing.T) {
|
func TestTOMLTest_Invalid_Datetime_NoT(t *testing.T) {
|
||||||
input := "no-t = 1987-07-0517:45:00Z\n"
|
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)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Datetime_TrailingT(t *testing.T) {
|
func TestTOMLTest_Invalid_Datetime_TrailingT(t *testing.T) {
|
||||||
input := "d = 2006-01-30T\n"
|
input := "# Date cannot end with trailing T\nd = 2006-01-30T\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,6 +485,11 @@ func TestTOMLTest_Invalid_InlineTable_NoComma(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
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) {
|
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"
|
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)
|
testgenInvalid(t, input)
|
||||||
@@ -515,6 +570,11 @@ func TestTOMLTest_Invalid_Integer_LeadingZero2(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
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) {
|
func TestTOMLTest_Invalid_Integer_LeadingZeroSign1(t *testing.T) {
|
||||||
input := "leading-zero-sign-1 = -01\n"
|
input := "leading-zero-sign-1 = -01\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -525,6 +585,11 @@ func TestTOMLTest_Invalid_Integer_LeadingZeroSign2(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
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) {
|
func TestTOMLTest_Invalid_Integer_NegativeBin(t *testing.T) {
|
||||||
input := "negative-bin = -0b11010110\n"
|
input := "negative-bin = -0b11010110\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -730,11 +795,16 @@ func TestTOMLTest_Invalid_String_BadConcat(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_String_BadEscape(t *testing.T) {
|
func TestTOMLTest_Invalid_String_BadEscape1(t *testing.T) {
|
||||||
input := "invalid-escape = \"This string has a bad \\a escape character.\"\n"
|
input := "invalid-escape = \"This string has a bad \\a escape character.\"\n"
|
||||||
testgenInvalid(t, input)
|
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) {
|
func TestTOMLTest_Invalid_String_BadMultiline(t *testing.T) {
|
||||||
input := "multi = \"first line\nsecond line\"\n"
|
input := "multi = \"first line\nsecond line\"\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -805,6 +875,21 @@ func TestTOMLTest_Invalid_String_MissingQuotes(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
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) {
|
func TestTOMLTest_Invalid_String_MultilineEscapeSpace(t *testing.T) {
|
||||||
input := "a = \"\"\"\n foo \\ \\n\n bar\"\"\"\n"
|
input := "a = \"\"\"\n foo \\ \\n\n bar\"\"\"\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -845,6 +930,16 @@ func TestTOMLTest_Invalid_String_WrongClose(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTOMLTest_Invalid_Table_AppendWithDottedKeys1(t *testing.T) {
|
||||||
|
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"
|
||||||
|
testgenInvalid(t, input)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTOMLTest_Invalid_Table_AppendWithDottedKeys2(t *testing.T) {
|
||||||
|
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"
|
||||||
|
testgenInvalid(t, input)
|
||||||
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Table_ArrayEmpty(t *testing.T) {
|
func TestTOMLTest_Invalid_Table_ArrayEmpty(t *testing.T) {
|
||||||
input := "[[]]\nname = \"Born to Run\"\n"
|
input := "[[]]\nname = \"Born to Run\"\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -860,6 +955,16 @@ func TestTOMLTest_Invalid_Table_ArrayMissingBracket(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTOMLTest_Invalid_Table_DuplicateKeyDottedTable(t *testing.T) {
|
||||||
|
input := "[fruit]\napple.color = \"red\"\n\n[fruit.apple] # INVALID\n"
|
||||||
|
testgenInvalid(t, input)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTOMLTest_Invalid_Table_DuplicateKeyDottedTable2(t *testing.T) {
|
||||||
|
input := "[fruit]\napple.taste.sweet = true\n\n[fruit.apple.taste] # INVALID\n"
|
||||||
|
testgenInvalid(t, input)
|
||||||
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Table_DuplicateKeyTable(t *testing.T) {
|
func TestTOMLTest_Invalid_Table_DuplicateKeyTable(t *testing.T) {
|
||||||
input := "[fruit]\ntype = \"apple\"\n\n[fruit.type]\napple = \"yes\"\n"
|
input := "[fruit]\ntype = \"apple\"\n\n[fruit.type]\napple = \"yes\"\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -895,16 +1000,6 @@ func TestTOMLTest_Invalid_Table_EqualsSign(t *testing.T) {
|
|||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Table_Injection1(t *testing.T) {
|
|
||||||
input := "[a.b.c]\n z = 9\n[a]\n b.c.t = \"Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed\"\n \n# see https://github.com/toml-lang/toml/issues/846\n"
|
|
||||||
testgenInvalid(t, input)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Table_Injection2(t *testing.T) {
|
|
||||||
input := "[a.b.c.d]\n z = 9\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 \n# see https://github.com/toml-lang/toml/issues/846\n"
|
|
||||||
testgenInvalid(t, input)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTOMLTest_Invalid_Table_Llbrace(t *testing.T) {
|
func TestTOMLTest_Invalid_Table_Llbrace(t *testing.T) {
|
||||||
input := "[ [table]]\n"
|
input := "[ [table]]\n"
|
||||||
testgenInvalid(t, input)
|
testgenInvalid(t, input)
|
||||||
@@ -1071,8 +1166,14 @@ func TestTOMLTest_Valid_Comment_AtEof2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Valid_Comment_Everywhere(t *testing.T) {
|
func TestTOMLTest_Valid_Comment_Everywhere(t *testing.T) {
|
||||||
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.\nd = 1979-05-27T07:32:12-07:00 # c\n"
|
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"
|
||||||
jsonRef := "{\n \"group\": {\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n \"d\": {\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"
|
jsonRef := "{\n \"group\": {\n \"answer\": {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n \"dt\": {\n \"type\": \"datetime\",\n \"value\": \"1979-05-27T07:32:12-07:00\"\n },\n \"d\": {\n \"type\": \"date-local\",\n \"value\": \"1979-05-27\"\n },\n \"more\": [\n {\n \"type\": \"integer\",\n \"value\": \"42\"\n },\n {\n \"type\": \"integer\",\n \"value\": \"42\"\n }\n ]\n }\n}\n"
|
||||||
|
testgenValid(t, input, jsonRef)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTOMLTest_Valid_Comment_Noeol(t *testing.T) {
|
||||||
|
input := "# single comment without any eol characters"
|
||||||
|
jsonRef := "{}\n"
|
||||||
testgenValid(t, input, jsonRef)
|
testgenValid(t, input, jsonRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1107,8 +1208,8 @@ func TestTOMLTest_Valid_Datetime_Local(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Valid_Datetime_Milliseconds(t *testing.T) {
|
func TestTOMLTest_Valid_Datetime_Milliseconds(t *testing.T) {
|
||||||
input := "utc1 = 1987-07-05T17:45:56.123456Z\nutc2 = 1987-07-05T17:45:56.6Z\nwita1 = 1987-07-05T17:45:56.123456+08:00\nwita2 = 1987-07-05T17:45:56.6+08:00\n"
|
input := "utc1 = 1987-07-05T17:45:56.1234Z\nutc2 = 1987-07-05T17:45:56.6Z\nwita1 = 1987-07-05T17:45:56.1234+08:00\nwita2 = 1987-07-05T17:45:56.6+08:00\n"
|
||||||
jsonRef := "{\n \"utc1\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.123456Z\"\n },\n \"utc2\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.600000Z\"\n },\n \"wita1\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.123456+08:00\"\n },\n \"wita2\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.600000+08:00\"\n }\n}\n"
|
jsonRef := "{\n \"utc1\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.1234Z\"\n },\n \"utc2\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.6000Z\"\n },\n \"wita1\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.1234+08:00\"\n },\n \"wita2\": {\n \"type\": \"datetime\",\n \"value\": \"1987-07-05T17:45:56.6000+08:00\"\n }\n}\n"
|
||||||
testgenValid(t, input, jsonRef)
|
testgenValid(t, input, jsonRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1395,7 +1496,7 @@ func TestTOMLTest_Valid_String_MultilineQuotes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Valid_String_Multiline(t *testing.T) {
|
func TestTOMLTest_Valid_String_Multiline(t *testing.T) {
|
||||||
input := "# NOTE: this file includes some literal tab characters.\n\nmultiline_empty_one = \"\"\"\"\"\"\nmultiline_empty_two = \"\"\"\n\"\"\"\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\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"
|
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"
|
||||||
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"
|
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"
|
||||||
testgenValid(t, input, jsonRef)
|
testgenValid(t, input, jsonRef)
|
||||||
}
|
}
|
||||||
@@ -1407,7 +1508,7 @@ func TestTOMLTest_Valid_String_Nl(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTOMLTest_Valid_String_RawMultiline(t *testing.T) {
|
func TestTOMLTest_Valid_String_RawMultiline(t *testing.T) {
|
||||||
input := "oneline = '''This string has a ' quote character.'''\nfirstnl = '''\nThis string has a ' quote character.'''\nmultiline = '''\nThis string\nhas ' a quote character\nand more than\none newline\nin it.'''\n"
|
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"
|
||||||
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 \"oneline\": {\n \"type\": \"string\",\n \"value\": \"This string has a ' quote character.\"\n }\n}\n"
|
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 \"oneline\": {\n \"type\": \"string\",\n \"value\": \"This string has a ' quote character.\"\n }\n}\n"
|
||||||
testgenValid(t, input, jsonRef)
|
testgenValid(t, input, jsonRef)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user