summaryrefslogtreecommitdiff
path: root/xmpp/jid_test.go
blob: 7b6874a230f23cc3cc796047f8fe7ce1db8608da (plain)
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
29
30
31
32
33
34
35
36
37
38
package xmpp

import (
	"testing"
)

func TestDomainpart(t *testing.T) {
	var data = map[string]string{
		"user@example.org/ressource": "example.org",
		"example.org/ressource":      "example.org",
		"user@example.org":           "example.org",
		"example.org":                "example.org",
		"test.eu":                    "test.eu",
	}

	for k, v := range data {
		if domainpart(k) != v {
			t.Fatalf("Domain part of JID '%s' is not '%s'!", k, v)
		}
	}
}

func TestUsername(t *testing.T) {
	var data = map[string]string{
		"user@example.org/ressource": "user",
		"example.org/ressource":      "",
		"user@example.org":           "user",
		"df%§df?LÖ@example.org":      "df%§df?LÖ",
		"example.org":                "",
		"test.eu":                    "",
	}

	for k, v := range data {
		if username(k) != v {
			t.Fatalf("Username of JID '%s' is not '%s'!", k, v)
		}
	}
}