package ast import ( "testing" "time" ) func Test_StringFormatting(t *testing.T) { testAST(t, func() (error, *parser) { tableData := make(table) tableData["x"] = newItem(tBoolean, true) tableData["y"] = newItem(tInteger, 42) dateTime, _ := time.Parse(time.RFC3339Nano, "2003-11-01T01:02:03.999999999+10:00") p := newParser() p.setKeyValuePair(newKey("a"), newItem(tInteger, 1)) p.setKeyValuePair(newKey("b"), newItem(tFloat, 2.3)) p.setKeyValuePair(newKey("c"), newItem(tBoolean, true)) p.setKeyValuePair(newKey("d"), newItem(tString, "foo")) p.setKeyValuePair(newKey("e"), newItem(tArray, newItem(tInteger, 1), newItem(tInteger, 2))) p.setKeyValuePair(newKey("f"), newItem(tTable, tableData)) p.setKeyValuePair(newKey("g"), newItem(tOffsetDateTime, dateTime)) p.setKeyValuePair(newKey("h"), newItem(tLocalDateTime, dateTime)) p.setKeyValuePair(newKey("i"), newItem(tLocalDate, dateTime)) p.setKeyValuePair(newKey("j"), newItem(tLocalTime, dateTime)) return nil, p }, "", `{"a": 1, `+ `"b": 2.3, `+ `"c": true, `+ `"d": "foo", `+ `"e": [1, 2], `+ `"f": {"x": true, "y": 42}, `+ `"g": 2003-11-01T01:02:03.999999999+10:00, `+ `"h": 2003-11-01 01:02:03.999999999, `+ `"i": 2003-11-01, `+ `"j": 01:02:03.999999999}`) }