Address a bug that can happen if no SRV records can be found.
// Copyright 2011 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.packagexmppimport("encoding/xml""reflect""testing")// This is mostly just tests of the roster data structures.funcTestRosterIqMarshal(t*testing.T){iq:=&Iq{Header:Header{From:"from",Lang:"en",Nested:[]interface{}{RosterQuery{}}}}exp:=`<iq from="from" xml:lang="en"><query xmlns="`+NsRoster+`"></query></iq>`assertMarshal(t,exp,iq)}funcTestRosterIqUnmarshal(t*testing.T){str:=`<iq from="from" xml:lang="en"><query xmlns="`+NsRoster+`"><item jid="a@b.c"/></query></iq>`iq:=Iq{}xml.Unmarshal([]byte(str),&iq)m:=make(map[xml.Name]reflect.Type)name:=xml.Name{Space:NsRoster,Local:"query"}m[name]=reflect.TypeOf(RosterQuery{})err:=parseExtended(&iq.Header,m)iferr!=nil{t.Fatalf("parseExtended: %v",err)}assertEquals(t,"iq",iq.XMLName.Local)assertEquals(t,"from",iq.From)assertEquals(t,"en",iq.Lang)nested:=iq.Nestedifnested==nil{t.Fatalf("nested nil")}iflen(nested)!=1{t.Fatalf("wrong size nested(%d): %v",len(nested),nested)}varrq*RosterQueryrq,ok:=nested[0].(*RosterQuery)if!ok{t.Fatalf("nested not RosterQuery: %v",reflect.TypeOf(nested))}iflen(rq.Item)!=1{t.Fatalf("Wrong # items: %v",rq.Item)}item:=rq.Item[0]assertEquals(t,"a@b.c",item.Jid)}