MCPcopy Create free account
hub / github.com/devfeel/mapper / Test_MapperSlice

Function Test_MapperSlice

mapper_test.go:208–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func Test_MapperSlice(t *testing.T) {
209 SetEnabledTypeChecking(true)
210 var fromSlice []*FromStruct
211 var toSlice []*ToStruct
212 for i := 0; i < 10; i++ {
213 fromSlice = append(fromSlice, &FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
214 }
215 err := MapperSlice(fromSlice, &toSlice)
216 if err != nil {
217 t.Error(err)
218 } else {
219 t.Log(toSlice, len(toSlice))
220 for i := 0; i < len(fromSlice); i++ {
221 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
222 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
223 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
224 t.Fail()
225 }
226 }
227 }
228}
229
230func Test_MapperSlice2(t *testing.T) {
231 SetEnabledTypeChecking(true)

Callers

nothing calls this directly

Calls 2

SetEnabledTypeCheckingFunction · 0.85
MapperSliceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…