File: address_test.go

package info (click to toggle)
golang-github-emersion-go-message 0.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 348 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 970 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
29
30
package mail_test

import (
	"net/mail"
	"reflect"
	"testing"
)

func TestParseAddressList(t *testing.T) {
	want := []*mail.Address{{"Mitsuha Miyamizu", "mitsuha.miyamizu@example.org"},
		{"Han Solo", "hanibunny@example.org"},
	}
	input := "Mitsuha Miyamizu <mitsuha.miyamizu@example.org>,Han Solo <hanibunny@example.org>"
	if got, err := mail.ParseAddressList(input); err != nil {
		t.Error("Expected no error while parsing address list got:", err)
	} else if !reflect.DeepEqual(got, want) {
		t.Errorf("Expected address list to be %v, but got %v", want, got)
	}
}

func TestParseAddress(t *testing.T) {
	want := &mail.Address{"Mitsuha Miyamizu", "mitsuha.miyamizu@example.org"}
	input := "Mitsuha Miyamizu <mitsuha.miyamizu@example.org>"

	if got, err := mail.ParseAddress(input); err != nil {
		t.Error("Expected no error while parsing address got:", err)
	} else if !reflect.DeepEqual(got, want) {
		t.Errorf("Expected address to be %v, but got %v", want, got)
	}
}