TestSortValuesWithSpew ensures the sort functionality for reflect.Value based sorting works as intended when using spew to stringify keys.
(t *testing.T)
| 266 | // TestSortValuesWithSpew ensures the sort functionality for reflect.Value |
| 267 | // based sorting works as intended when using spew to stringify keys. |
| 268 | func TestSortValuesWithSpew(t *testing.T) { |
| 269 | v := reflect.ValueOf |
| 270 | |
| 271 | a := v("a") |
| 272 | b := v("b") |
| 273 | c := v("c") |
| 274 | tests := []sortTestCase{ |
| 275 | // Ints. |
| 276 | { |
| 277 | []reflect.Value{v(2), v(1), v(3)}, |
| 278 | []reflect.Value{v(1), v(2), v(3)}, |
| 279 | }, |
| 280 | // Strings. |
| 281 | { |
| 282 | []reflect.Value{b, a, c}, |
| 283 | []reflect.Value{a, b, c}, |
| 284 | }, |
| 285 | // SortableStructs. |
| 286 | { |
| 287 | []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, |
| 288 | []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, |
| 289 | }, |
| 290 | // UnsortableStructs. |
| 291 | { |
| 292 | []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, |
| 293 | []reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})}, |
| 294 | }, |
| 295 | } |
| 296 | cs := spew.ConfigState{DisableMethods: true, SpewKeys: true} |
| 297 | helpTestSortValues(tests, &cs, t) |
| 298 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…