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

Function Test_Object_MapperStructSlice2

mapper_object_test.go:225–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

223}
224
225func Test_Object_MapperStructSlice2(t *testing.T) {
226 m := NewMapper()
227 m.SetEnabledTypeChecking(true)
228 var fromSlice []FromStruct
229 var toSlice []ToStruct
230 for i := 0; i < 10; i++ {
231 fromSlice = append(fromSlice, FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
232 }
233 err := m.MapperSlice(&fromSlice, &toSlice)
234 if err != nil {
235 t.Error(err)
236 } else {
237 t.Log(toSlice, len(toSlice))
238 for i := 0; i < len(fromSlice); i++ {
239 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
240 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
241 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
242 t.Fail()
243 }
244 }
245 }
246}
247
248func BenchmarkObjectMapperSlice(b *testing.B) {
249 m := NewMapper()

Callers

nothing calls this directly

Calls 3

NewMapperFunction · 0.85
MapperSliceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…