mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-25 12:02:01 -08:00
30 lines
697 B
Go
30 lines
697 B
Go
|
package xmpp_test // import "gosrc.io/xmpp_test"
|
||
|
|
||
|
import (
|
||
|
"encoding/xml"
|
||
|
|
||
|
"github.com/google/go-cmp/cmp"
|
||
|
)
|
||
|
|
||
|
// Compare iq structure but ignore empty namespace as they are set properly on
|
||
|
// marshal / unmarshal. There is no need to manage them on the manually
|
||
|
// crafted structure.
|
||
|
func xmlEqual(x, y interface{}) bool {
|
||
|
alwaysEqual := cmp.Comparer(func(_, _ interface{}) bool { return true })
|
||
|
opts := cmp.Options{
|
||
|
cmp.FilterValues(func(x, y interface{}) bool {
|
||
|
xx, xok := x.(xml.Name)
|
||
|
yy, yok := y.(xml.Name)
|
||
|
if xok && yok {
|
||
|
zero := xml.Name{}
|
||
|
if xx == zero || yy == zero {
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}, alwaysEqual),
|
||
|
}
|
||
|
|
||
|
return cmp.Equal(x, y, opts)
|
||
|
}
|