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

Function TestEncodeMapFlattenShape

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

Source from the content-addressed store, hash-verified

256}
257
258func TestEncodeMapFlattenShape(t *testing.T) {
259 b := bytes.NewBuffer(nil)
260 encoder := xml.NewEncoder(b)
261
262 func() {
263 r := encoder.RootElement(root)
264 defer r.Close()
265 // nested `mapStr` shape
266 mapstr := xml.StartElement{Name: xml.Name{Local: "mapShape"}}
267 flatElement := r.FlattenedElement(mapstr)
268 m := flatElement.Map()
269
270 e := m.Entry()
271 defer e.Close()
272
273 key := xml.StartElement{Name: xml.Name{Local: "key"}}
274 e.MemberElement(key).String("abc")
275
276 value := xml.StartElement{Name: xml.Name{Local: "value"}}
277 n1 := e.MemberElement(value)
278 defer n1.Close()
279
280 shapeVal := xml.StartElement{Name: xml.Name{Local: "shapeVal"}}
281 n1.MemberElement(shapeVal).Integer(1)
282 }()
283 ex := []byte(`<root><mapShape><key>abc</key><value><shapeVal>1</shapeVal></value></mapShape></root>`)
284 verify(t, encoder, ex)
285}
286
287func TestEncodeMapNamedShape(t *testing.T) {
288 b := bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected