Skip to content

Commit 12d1abd

Browse files
add more unit test
1 parent c9b5e20 commit 12d1abd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jsonschema/schema_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ func TestJSONRoundTrip(t *testing.T) {
6565
`{"$vocabulary":{"b":true, "a":false}}`,
6666
`{"$vocabulary":{"a":false,"b":true}}`,
6767
},
68-
{`{"unk":0}`, `{"unk":0}`}, // unknown fields are not dropped
68+
{`{"unk":0}`, `{"unk":0}`}, // unknown fields are not dropped
69+
{
70+
// known and unknown fields are not dropped
71+
// note that the order will be by the declaration order in the anonymous struct inside MarshalJSON
72+
`{"comment":"test","type":"example","unk":0}`,
73+
`{"type":"example","comment":"test","unk":0}`,
74+
},
6975
{`{"extra":0}`, `{"extra":0}`}, // extra is not a special keyword and should not be dropped
7076
{`{"Extra":0}`, `{"Extra":0}`}, // Extra is not a special keyword and should not be dropped
7177
} {

0 commit comments

Comments
 (0)