(t *testing.T)
| 992 | } |
| 993 | |
| 994 | func TestDumpSortedKeys(t *testing.T) { |
| 995 | cfg := spew.ConfigState{SortKeys: true} |
| 996 | s := cfg.Sdump(map[int]string{1: "1", 3: "3", 2: "2"}) |
| 997 | expected := "(map[int]string) (len=3) {\n(int) 1: (string) (len=1) " + |
| 998 | "\"1\",\n(int) 2: (string) (len=1) \"2\",\n(int) 3: (string) " + |
| 999 | "(len=1) \"3\"\n" + |
| 1000 | "}\n" |
| 1001 | if s != expected { |
| 1002 | t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) |
| 1003 | } |
| 1004 | |
| 1005 | s = cfg.Sdump(map[stringer]int{"1": 1, "3": 3, "2": 2}) |
| 1006 | expected = "(map[spew_test.stringer]int) (len=3) {\n" + |
| 1007 | "(spew_test.stringer) (len=1) stringer 1: (int) 1,\n" + |
| 1008 | "(spew_test.stringer) (len=1) stringer 2: (int) 2,\n" + |
| 1009 | "(spew_test.stringer) (len=1) stringer 3: (int) 3\n" + |
| 1010 | "}\n" |
| 1011 | if s != expected { |
| 1012 | t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) |
| 1013 | } |
| 1014 | |
| 1015 | s = cfg.Sdump(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) |
| 1016 | expected = "(map[spew_test.pstringer]int) (len=3) {\n" + |
| 1017 | "(spew_test.pstringer) (len=1) stringer 1: (int) 1,\n" + |
| 1018 | "(spew_test.pstringer) (len=1) stringer 2: (int) 2,\n" + |
| 1019 | "(spew_test.pstringer) (len=1) stringer 3: (int) 3\n" + |
| 1020 | "}\n" |
| 1021 | if spew.UnsafeDisabled { |
| 1022 | expected = "(map[spew_test.pstringer]int) (len=3) {\n" + |
| 1023 | "(spew_test.pstringer) (len=1) \"1\": (int) 1,\n" + |
| 1024 | "(spew_test.pstringer) (len=1) \"2\": (int) 2,\n" + |
| 1025 | "(spew_test.pstringer) (len=1) \"3\": (int) 3\n" + |
| 1026 | "}\n" |
| 1027 | } |
| 1028 | if s != expected { |
| 1029 | t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) |
| 1030 | } |
| 1031 | |
| 1032 | s = cfg.Sdump(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) |
| 1033 | expected = "(map[spew_test.customError]int) (len=3) {\n" + |
| 1034 | "(spew_test.customError) error: 1: (int) 1,\n" + |
| 1035 | "(spew_test.customError) error: 2: (int) 2,\n" + |
| 1036 | "(spew_test.customError) error: 3: (int) 3\n" + |
| 1037 | "}\n" |
| 1038 | if s != expected { |
| 1039 | t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) |
| 1040 | } |
| 1041 | |
| 1042 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…