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

Function Test_Object_MapperSlice

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

Source from the content-addressed store, hash-verified

154}
155
156func Test_Object_MapperSlice(t *testing.T) {
157 m := NewMapper()
158 m.SetEnabledTypeChecking(true)
159 var fromSlice []*FromStruct
160 var toSlice []*ToStruct
161 for i := 0; i < 10; i++ {
162 fromSlice = append(fromSlice, &FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
163 }
164 err := m.MapperSlice(fromSlice, &toSlice)
165 if err != nil {
166 t.Error(err)
167 } else {
168 t.Log(toSlice, len(toSlice))
169 for i := 0; i < len(fromSlice); i++ {
170 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
171 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
172 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
173 t.Fail()
174 }
175 }
176 }
177}
178
179func Test_Object_MapperSlice2(t *testing.T) {
180 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…