--- a/roster_test.go Mon Jan 23 21:54:41 2012 -0700
+++ b/roster_test.go Sun Dec 16 13:03:03 2012 -0700
@@ -5,16 +5,16 @@
package xmpp
import (
+ "encoding/xml"
"reflect"
- "strings"
"testing"
- "xml"
)
// This is mostly just tests of the roster data structures.
func TestRosterIqMarshal(t *testing.T) {
- iq := &Iq{From: "from", Lang: "en", Nested: []interface{}{RosterQuery{}}}
+ iq := &Iq{From: "from", Lang: "en",
+ Nested: []interface{}{RosterQuery{}}}
exp := `<iq from="from" xml:lang="en"><query xmlns="` +
NsRoster + `"></query></iq>`
assertMarshal(t, exp, iq)
@@ -23,18 +23,17 @@
func TestRosterIqUnmarshal(t *testing.T) {
str := `<iq from="from" xml:lang="en"><query xmlns="` +
NsRoster + `"><item jid="a@b.c"/></query></iq>`
- r := strings.NewReader(str)
- var st Stanza = &Iq{}
- xml.Unmarshal(r, st)
+ iq := Iq{}
+ xml.Unmarshal([]byte(str), &iq)
m := map[string]func(*xml.Name) interface{}{NsRoster: newRosterQuery}
- err := parseExtended(st, m)
+ err := parseExtended(&iq, m)
if err != nil {
t.Fatalf("parseExtended: %v", err)
}
- assertEquals(t, "iq", st.GetName())
- assertEquals(t, "from", st.GetFrom())
- assertEquals(t, "en", st.GetLang())
- nested := st.GetNested()
+ assertEquals(t, "iq", iq.XMLName.Local)
+ assertEquals(t, "from", iq.From)
+ assertEquals(t, "en", iq.Lang)
+ nested := iq.Nested
if nested == nil {
t.Fatalf("nested nil")
}