MCPcopy Create free account
hub / github.com/aws/smithy-go / TestEncodeMapShape

Function TestEncodeMapShape

encoding/xml/encoder_test.go:225–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

223}
224
225func TestEncodeMapShape(t *testing.T) {
226 b := bytes.NewBuffer(nil)
227 encoder := xml.NewEncoder(b)
228
229 func() {
230 r := encoder.RootElement(root)
231 defer r.Close()
232
233 // nested `mapStr` shape
234 mapstr := xml.StartElement{Name: xml.Name{Local: "mapShape"}}
235 mapElement := r.MemberElement(mapstr)
236 defer mapElement.Close()
237
238 m := mapElement.Map()
239
240 e := m.Entry()
241 defer e.Close()
242
243 key := xml.StartElement{Name: xml.Name{Local: "key"}}
244 e.MemberElement(key).String("abc")
245
246 value := xml.StartElement{Name: xml.Name{Local: "value"}}
247 n1 := e.MemberElement(value)
248 defer n1.Close()
249
250 shapeVal := xml.StartElement{Name: xml.Name{Local: "shapeVal"}}
251 n1.MemberElement(shapeVal).Integer(1)
252 }()
253
254 ex := []byte(`<root><mapShape><entry><key>abc</key><value><shapeVal>1</shapeVal></value></entry></mapShape></root>`)
255 verify(t, encoder, ex)
256}
257
258func TestEncodeMapFlattenShape(t *testing.T) {
259 b := bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 9

RootElementMethod · 0.95
NewEncoderFunction · 0.92
verifyFunction · 0.85
MemberElementMethod · 0.80
MapMethod · 0.80
EntryMethod · 0.80
StringMethod · 0.65
CloseMethod · 0.45
IntegerMethod · 0.45

Tested by

no test coverage detected