structs_test.go
changeset 72 53f15893a1a7
parent 71 578c2a83dc18
child 74 e619e18dcec3
child 98 c9cc4eda6dce
equal deleted inserted replaced
71:578c2a83dc18 72:53f15893a1a7
    69 
    69 
    70 func TestStreamErrorMarshal(t *testing.T) {
    70 func TestStreamErrorMarshal(t *testing.T) {
    71 	name := xml.Name{Space: NsStreams, Local: "ack"}
    71 	name := xml.Name{Space: NsStreams, Local: "ack"}
    72 	e := &streamError{Any: Generic{XMLName: name}}
    72 	e := &streamError{Any: Generic{XMLName: name}}
    73 	exp := `<stream:error><ack xmlns="` + NsStreams +
    73 	exp := `<stream:error><ack xmlns="` + NsStreams +
    74 		`"></ack></stream:error>`;
    74 		`"></ack></stream:error>`
    75 	assertMarshal(t, exp, e)
    75 	assertMarshal(t, exp, e)
    76 
    76 
    77 	txt := errText{Lang: "pt", Text: "things happen"}
    77 	txt := errText{Lang: "pt", Text: "things happen"}
    78 	e = &streamError{Any: Generic{XMLName: name}, Text: &txt}
    78 	e = &streamError{Any: Generic{XMLName: name}, Text: &txt}
    79 	exp = `<stream:error><ack xmlns="` + NsStreams +
    79 	exp = `<stream:error><ack xmlns="` + NsStreams +
    81 		`" xml:lang="pt">things happen</text></stream:error>`
    81 		`" xml:lang="pt">things happen</text></stream:error>`
    82 	assertMarshal(t, exp, e)
    82 	assertMarshal(t, exp, e)
    83 }
    83 }
    84 
    84 
    85 func TestIqMarshal(t *testing.T) {
    85 func TestIqMarshal(t *testing.T) {
    86 	iq := &Iq{Type: "set", Id: "3", Nested:
    86 	iq := &Iq{Type: "set", Id: "3", Nested: []interface{}{Generic{XMLName: xml.Name{Space: NsBind,
    87 		[]interface{}{Generic{XMLName: xml.Name{Space: NsBind,
    87 		Local: "bind"}}}}
    88 				Local: "bind"}}}}
       
    89 	exp := `<iq id="3" type="set"><bind xmlns="` + NsBind +
    88 	exp := `<iq id="3" type="set"><bind xmlns="` + NsBind +
    90 		`"></bind></iq>`
    89 		`"></bind></iq>`
    91 	assertMarshal(t, exp, iq)
    90 	assertMarshal(t, exp, iq)
    92 }
    91 }
    93 
    92