diff --git a/encode_test.go b/encode_test.go index c7afadb7..63740f35 100644 --- a/encode_test.go +++ b/encode_test.go @@ -1022,12 +1022,13 @@ func (u *unmarshalerText) UnmarshalText(b []byte) error { } func TestTextMarshalerMapKeysAreSorted(t *testing.T) { - b, err := json.Marshal(map[unmarshalerText]int{ + data := map[unmarshalerText]int{ {"x", "y"}: 1, {"y", "x"}: 2, {"a", "z"}: 3, {"z", "a"}: 4, - }) + } + b, err := json.Marshal(data) if err != nil { t.Fatalf("Failed to Marshal text.Marshaler: %v", err) } @@ -1035,6 +1036,14 @@ func TestTextMarshalerMapKeysAreSorted(t *testing.T) { if string(b) != want { t.Errorf("Marshal map with text.Marshaler keys: got %#q, want %#q", b, want) } + + b, err = stdjson.Marshal(data) + if err != nil { + t.Fatalf("Failed to std Marshal text.Marshaler: %v", err) + } + if string(b) != want { + t.Errorf("std Marshal map with text.Marshaler keys: got %#q, want %#q", b, want) + } } // https://golang.org/issue/33675