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

Function helpTestSortValues

internal/spew/common_test.go:134–155  ·  view source on GitHub ↗
(tests []sortTestCase, cs *spew.ConfigState, t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func 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.

Callers 3

TestSortValuesFunction · 0.85
TestSortValuesWithSpewFunction · 0.85

Calls 2

SortValuesFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…