(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func TestDeterministicMapOrder(t *testing.T) { |
| 71 | value := struct { |
| 72 | Map map[string]string |
| 73 | }{ |
| 74 | Map: map[string]string{ |
| 75 | "foo": "bar", |
| 76 | "a": "b", |
| 77 | "bar": "baz", |
| 78 | "b": "c", |
| 79 | "baz": "qux", |
| 80 | "c": "d", |
| 81 | }, |
| 82 | } |
| 83 | expect := `{"Map":{"a":"b","b":"c","bar":"baz","baz":"qux","c":"d","foo":"bar"}}` |
| 84 | |
| 85 | encoder := json.NewEncoder() |
| 86 | actual, err := encoder.Encode(value) |
| 87 | if err != nil { |
| 88 | t.Fatal(err) |
| 89 | } |
| 90 | |
| 91 | if expect != string(actual) { |
| 92 | t.Errorf("encode determinstic order:\n%q !=\n%q", expect, actual) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func TestDocumentNumberEncodesAsNumber(t *testing.T) { |
| 97 | encoder := json.NewEncoder() |
nothing calls this directly
no test coverage detected