MCPcopy Index your code
hub / github.com/foxcpp/maddy / TestSplit

Function TestSplit

framework/address/split_test.go:25–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestSplit(t *testing.T) {
26 test := func(addr, mbox, domain string, fail bool) {
27 t.Helper()
28
29 actualMbox, actualDomain, err := Split(addr)
30 if err != nil && !fail {
31 t.Errorf("%s: unexpected error: %v", addr, err)
32 return
33 }
34 if err == nil && fail {
35 t.Errorf("%s: expected error, got %s, %s", addr, actualMbox, actualDomain)
36 return
37 }
38
39 if actualMbox != mbox {
40 t.Errorf("%s: wrong local part, want %s, got %s", addr, mbox, actualMbox)
41 }
42 if actualDomain != domain {
43 t.Errorf("%s: wrong domain part, want %s, got %s", addr, domain, actualDomain)
44 }
45 }
46
47 test("simple@example.org", "simple", "example.org", false)
48 test("simple@[1.2.3.4]", "simple", "[1.2.3.4]", false)
49 test("simple@[IPv6:beef::1]", "simple", "[IPv6:beef::1]", false)
50 test("@example.org", "", "", true)
51 test("@", "", "", true)
52 test("no-domain@", "", "", true)
53 test("@no-local-part", "", "", true)
54
55 // Not a valid address, but a special value for SMTP
56 // should be handled separately where necessary.
57 test("", "", "", true)
58
59 // A special SMTP value too, but permitted now.
60 test("postmaster", "postmaster", "", false)
61}
62
63func TestUnquoteMbox(t *testing.T) {
64 test := func(inputMbox, expectedMbox string, fail bool) {

Callers

nothing calls this directly

Calls 2

SplitFunction · 0.85
testStruct · 0.85

Tested by

no test coverage detected