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

Function Test_MapperSlice2

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

Source from the content-addressed store, hash-verified

228}
229
230func Test_MapperSlice2(t *testing.T) {
231 SetEnabledTypeChecking(true)
232 var fromSlice []*FromStruct
233 var toSlice []*ToStruct
234 for i := 0; i < 10; i++ {
235 fromSlice = append(fromSlice, &FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
236 }
237 err := MapperSlice(&fromSlice, &toSlice)
238 if err != nil {
239 t.Error(err)
240 } else {
241 t.Log(toSlice, len(toSlice))
242 for i := 0; i < len(fromSlice); i++ {
243 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
244 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
245 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
246 t.Fail()
247 }
248 }
249 }
250}
251
252func Test_MapperStructSlice(t *testing.T) {
253 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…