| 1429 | } |
| 1430 | |
| 1431 | func TestGithubIssue15(t *testing.T) { |
| 1432 | // https://github.com/segmentio/encoding/issues/15 |
| 1433 | tests := []struct { |
| 1434 | m any |
| 1435 | s string |
| 1436 | }{ |
| 1437 | { |
| 1438 | m: map[uint]bool{1: true, 123: true, 333: true, 42: true}, |
| 1439 | s: `{"1":true,"123":true,"333":true,"42":true}`, |
| 1440 | }, |
| 1441 | { |
| 1442 | m: map[int]bool{-1: true, -123: true, 333: true, 42: true}, |
| 1443 | s: `{"-1":true,"-123":true,"333":true,"42":true}`, |
| 1444 | }, |
| 1445 | } |
| 1446 | |
| 1447 | for _, test := range tests { |
| 1448 | b, _ := Marshal(test.m) |
| 1449 | |
| 1450 | if string(b) != test.s { |
| 1451 | t.Error("map with integer keys must be ordered by their string representation, got", string(b)) |
| 1452 | } |
| 1453 | |
| 1454 | } |
| 1455 | } |
| 1456 | |
| 1457 | type sliceA []byte |
| 1458 | |