(tests []sortTestCase, cs *spew.ConfigState, t *testing.T)
| 132 | } |
| 133 | |
| 134 | func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) { |
| 135 | getInterfaces := func(values []reflect.Value) []interface{} { |
| 136 | interfaces := []interface{}{} |
| 137 | for _, v := range values { |
| 138 | interfaces = append(interfaces, v.Interface()) |
| 139 | } |
| 140 | return interfaces |
| 141 | } |
| 142 | |
| 143 | for _, test := range tests { |
| 144 | spew.SortValues(test.input, cs) |
| 145 | // reflect.DeepEqual cannot really make sense of reflect.Value, |
| 146 | // probably because of all the pointer tricks. For instance, |
| 147 | // v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{} |
| 148 | // instead. |
| 149 | input := getInterfaces(test.input) |
| 150 | expected := getInterfaces(test.expected) |
| 151 | if !reflect.DeepEqual(input, expected) { |
| 152 | t.Errorf("Sort mismatch:\n %v != %v", input, expected) |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // TestSortValues ensures the sort functionality for reflect.Value based sorting |
| 158 | // works as intended. |
no test coverage detected
searching dependent graphs…