Debian Codegraph @

jid_test.go

raw
1 package main
2
3 import (
4 "testing"
5 )
6
7 func TestMarshalJID(t *testing.T) {
8 jids := [...]string{"[email protected]", "[email protected]."}
9 for _, jid := range jids {
10 marshalledJid, err := MarshalJID(jid)
11 if err != nil {
12 t.Errorf("Failed to marshal JID: %v", err)
13 }
14 if marshalledJid != "[email protected]" {
15 t.Errorf("Expected '[email protected]', got '%s'", marshalledJid)
16 }
17 }
18 badJids := [...]string{
19 "@[email protected].", "@[email protected]",
20 "[email protected]/",
21 }
22 for _, jid := range badJids {
23 _, err := MarshalJID(jid)
24 if err == nil {
25 t.Errorf("Expected error, but got none")
26 }
27 }
28 }