(t *testing.T)
| 1514 | } |
| 1515 | |
| 1516 | func TestPrintSortedKeys(t *testing.T) { |
| 1517 | cfg := spew.ConfigState{SortKeys: true} |
| 1518 | s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"}) |
| 1519 | expected := "map[1:1 2:2 3:3]" |
| 1520 | if s != expected { |
| 1521 | t.Errorf("Sorted keys mismatch 1:\n %v %v", s, expected) |
| 1522 | } |
| 1523 | |
| 1524 | s = cfg.Sprint(map[stringer]int{"1": 1, "3": 3, "2": 2}) |
| 1525 | expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" |
| 1526 | if s != expected { |
| 1527 | t.Errorf("Sorted keys mismatch 2:\n %v %v", s, expected) |
| 1528 | } |
| 1529 | |
| 1530 | s = cfg.Sprint(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) |
| 1531 | expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" |
| 1532 | if spew.UnsafeDisabled { |
| 1533 | expected = "map[1:1 2:2 3:3]" |
| 1534 | } |
| 1535 | if s != expected { |
| 1536 | t.Errorf("Sorted keys mismatch 3:\n %v %v", s, expected) |
| 1537 | } |
| 1538 | |
| 1539 | s = cfg.Sprint(map[testStruct]int{{1}: 1, {3}: 3, {2}: 2}) |
| 1540 | expected = "map[ts.1:1 ts.2:2 ts.3:3]" |
| 1541 | if s != expected { |
| 1542 | t.Errorf("Sorted keys mismatch 4:\n %v %v", s, expected) |
| 1543 | } |
| 1544 | |
| 1545 | if !spew.UnsafeDisabled { |
| 1546 | s = cfg.Sprint(map[testStructP]int{{1}: 1, {3}: 3, {2}: 2}) |
| 1547 | expected = "map[ts.1:1 ts.2:2 ts.3:3]" |
| 1548 | if s != expected { |
| 1549 | t.Errorf("Sorted keys mismatch 5:\n %v %v", s, expected) |
| 1550 | } |
| 1551 | } |
| 1552 | |
| 1553 | s = cfg.Sprint(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) |
| 1554 | expected = "map[error: 1:1 error: 2:2 error: 3:3]" |
| 1555 | if s != expected { |
| 1556 | t.Errorf("Sorted keys mismatch 6:\n %v %v", s, expected) |
| 1557 | } |
| 1558 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…