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

Function Test_Object_MapperStructSlice

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

Source from the content-addressed store, hash-verified

200}
201
202func Test_Object_MapperStructSlice(t *testing.T) {
203 m := NewMapper()
204 m.SetEnabledTypeChecking(true)
205 var fromSlice []FromStruct
206 var toSlice []ToStruct
207 for i := 0; i < 10; i++ {
208 fromSlice = append(fromSlice, FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
209 }
210 err := m.MapperSlice(fromSlice, &toSlice)
211 if err != nil {
212 t.Error(err)
213 } else {
214 t.Log(toSlice, len(toSlice))
215 for i := 0; i < len(fromSlice); i++ {
216 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
217 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
218 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
219 t.Fail()
220 }
221 }
222 }
223}
224
225func Test_Object_MapperStructSlice2(t *testing.T) {
226 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…