File: jid_test.go

package info (click to toggle)
go-sendxmpp 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 332 kB
  • sloc: makefile: 11
file content (28 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"testing"
)

func TestMarshalJID(t *testing.T) {
	jids := [...]string{"user@example.com", "user@example.com."}
	for _, jid := range jids {
		marshalledJid, err := MarshalJID(jid)
		if err != nil {
			t.Errorf("Failed to marshal JID: %v", err)
		}
		if marshalledJid != "user@example.com" {
			t.Errorf("Expected 'user@example.com', got '%s'", marshalledJid)
		}
	}
	badJids := [...]string{
		"@user@example.com.", "@user@example.com",
		"user@example.com/",
	}
	for _, jid := range badJids {
		_, err := MarshalJID(jid)
		if err == nil {
			t.Errorf("Expected error, but got none")
		}
	}
}