tomltest: unmarshal JSONs for tests (#633)

Comparing the output and the expected results byte-wise means we get false
negative when order doesn't matter (for example the ValidTableKeyword test).
This commit is contained in:
Thomas Pelletier
2021-10-19 15:29:49 -04:00
committed by GitHub
parent df4bb061f8
commit 7ccaa2744e
2 changed files with 10 additions and 2 deletions
+10 -1
View File
@@ -41,5 +41,14 @@ func testgenValid(t *testing.T, input string, jsonRef string) {
} }
j, err := testsuite.ValueToTaggedJSON(doc) j, err := testsuite.ValueToTaggedJSON(doc)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, jsonRef, string(j)+"\n")
var ref interface{}
err = json.Unmarshal([]byte(jsonRef), &ref)
require.NoError(t, err)
var actual interface{}
err = json.Unmarshal([]byte(j), &actual)
require.NoError(t, err)
require.Equal(t, ref, actual)
} }
-1
View File
@@ -1492,7 +1492,6 @@ func TestTOMLTest_Valid_Table_Empty(t *testing.T) {
} }
func TestTOMLTest_Valid_Table_Keyword(t *testing.T) { func TestTOMLTest_Valid_Table_Keyword(t *testing.T) {
t.Skip("FIXME")
input := "[true]\n\n[false]\n\n[inf]\n\n[nan]\n\n\n" input := "[true]\n\n[false]\n\n[inf]\n\n[nan]\n\n\n"
jsonRef := "{\n \"true\": {},\n \"false\": {},\n \"inf\": {},\n \"nan\": {}\n}\n" jsonRef := "{\n \"true\": {},\n \"false\": {},\n \"inf\": {},\n \"nan\": {}\n}\n"
testgenValid(t, input, jsonRef) testgenValid(t, input, jsonRef)