| 320 | } |
| 321 | |
| 322 | func TestFormatKey(t *testing.T) { |
| 323 | examples := []struct { |
| 324 | key interface{} |
| 325 | want string |
| 326 | }{ |
| 327 | {"hello", "hello"}, |
| 328 | {"hello world", "hello-world"}, |
| 329 | {"", "?"}, |
| 330 | {true, "true"}, |
| 331 | {"a b\"c\nd;e\tf龜g", "a-b-c-d-e-f龜g"}, |
| 332 | } |
| 333 | |
| 334 | for i, ex := range examples { |
| 335 | t.Log("Example", i) |
| 336 | got := formatKey(ex.key) |
| 337 | if got != ex.want { |
| 338 | t.Errorf("formatKey(%#v) = %q want %q", ex.key, got, ex.want) |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | func TestFormatValue(t *testing.T) { |
| 344 | examples := []struct { |