(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func TestMapWithInternedString(t *testing.T) { |
| 114 | type M map[string]interface{} |
| 115 | |
| 116 | dict := []string{"hello world", "foo bar"} |
| 117 | |
| 118 | var buf bytes.Buffer |
| 119 | |
| 120 | enc := msgpack.NewEncoder(nil) |
| 121 | enc.ResetDict(&buf, dictMap(dict)) |
| 122 | |
| 123 | dec := msgpack.NewDecoder(nil) |
| 124 | dec.ResetDict(&buf, dict) |
| 125 | |
| 126 | for i := 0; i < 100; i++ { |
| 127 | in := M{ |
| 128 | "foo bar": "hello world", |
| 129 | "hello world": "foo bar", |
| 130 | "foo": "bar", |
| 131 | } |
| 132 | err := enc.Encode(in) |
| 133 | require.Nil(t, err) |
| 134 | |
| 135 | _, err = dec.DecodeInterface() |
| 136 | require.Nil(t, err) |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | func dictMap(dict []string) map[string]int { |
| 141 | m := make(map[string]int, len(dict)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…