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

Function Test_MapperStructSlice2

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

Source from the content-addressed store, hash-verified

272}
273
274func Test_MapperStructSlice2(t *testing.T) {
275 SetEnabledTypeChecking(true)
276 var fromSlice []FromStruct
277 var toSlice []ToStruct
278 for i := 0; i < 10; i++ {
279 fromSlice = append(fromSlice, FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
280 }
281 err := MapperSlice(&fromSlice, &toSlice)
282 if err != nil {
283 t.Error(err)
284 } else {
285 t.Log(toSlice, len(toSlice))
286 for i := 0; i < len(fromSlice); i++ {
287 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
288 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
289 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
290 t.Fail()
291 }
292 }
293 }
294}
295
296func BenchmarkMapperSlice(b *testing.B) {
297 var fromSlice []*FromStruct

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…