MCPcopy Index your code
hub / github.com/expr-lang/expr / TestSortValuesWithMethods

Function TestSortValuesWithMethods

internal/spew/common_test.go:233–264  ·  view source on GitHub ↗

TestSortValuesWithMethods ensures the sort functionality for reflect.Value based sorting works as intended when using string methods.

(t *testing.T)

Source from the content-addressed store, hash-verified

231// TestSortValuesWithMethods ensures the sort functionality for reflect.Value
232// based sorting works as intended when using string methods.
233func TestSortValuesWithMethods(t *testing.T) {
234 v := reflect.ValueOf
235
236 a := v("a")
237 b := v("b")
238 c := v("c")
239 tests := []sortTestCase{
240 // Ints.
241 {
242 []reflect.Value{v(2), v(1), v(3)},
243 []reflect.Value{v(1), v(2), v(3)},
244 },
245 // Strings.
246 {
247 []reflect.Value{b, a, c},
248 []reflect.Value{a, b, c},
249 },
250 // SortableStructs.
251 {
252 []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
253 []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
254 },
255 // UnsortableStructs.
256 {
257 // Note: not sorted - SpewKeys is false.
258 []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
259 []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
260 },
261 }
262 cs := spew.ConfigState{DisableMethods: false, SpewKeys: false}
263 helpTestSortValues(tests, &cs, t)
264}
265
266// TestSortValuesWithSpew ensures the sort functionality for reflect.Value
267// based sorting works as intended when using spew to stringify keys.

Callers

nothing calls this directly

Calls 1

helpTestSortValuesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…