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

Function Test_MapperStructSlice

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

Source from the content-addressed store, hash-verified

250}
251
252func Test_MapperStructSlice(t *testing.T) {
253 SetEnabledTypeChecking(true)
254 var fromSlice []FromStruct
255 var toSlice []ToStruct
256 for i := 0; i < 10; i++ {
257 fromSlice = append(fromSlice, FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
258 }
259 err := MapperSlice(fromSlice, &toSlice)
260 if err != nil {
261 t.Error(err)
262 } else {
263 t.Log(toSlice, len(toSlice))
264 for i := 0; i < len(fromSlice); i++ {
265 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
266 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
267 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
268 t.Fail()
269 }
270 }
271 }
272}
273
274func Test_MapperStructSlice2(t *testing.T) {
275 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…