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

Function Test_Object_MapperSlice2

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

Source from the content-addressed store, hash-verified

177}
178
179func Test_Object_MapperSlice2(t *testing.T) {
180 m := NewMapper()
181 m.SetEnabledTypeChecking(true)
182 var fromSlice []*FromStruct
183 var toSlice []*ToStruct
184 for i := 0; i < 10; i++ {
185 fromSlice = append(fromSlice, &FromStruct{Name: "From" + strconv.Itoa(i), Sex: true, AA: "AA" + strconv.Itoa(i)})
186 }
187 err := m.MapperSlice(&fromSlice, &toSlice)
188 if err != nil {
189 t.Error(err)
190 } else {
191 t.Log(toSlice, len(toSlice))
192 for i := 0; i < len(fromSlice); i++ {
193 if !reflect.DeepEqual(fromSlice[i].Name, toSlice[i].Name) ||
194 !reflect.DeepEqual(fromSlice[i].Sex, toSlice[i].Sex) ||
195 !reflect.DeepEqual(fromSlice[i].AA, toSlice[i].BB) {
196 t.Fail()
197 }
198 }
199 }
200}
201
202func Test_Object_MapperStructSlice(t *testing.T) {
203 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…