File: cfws_test.go

package info (click to toggle)
golang-github-protonmail-gluon 0.17.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,020 kB
  • sloc: sh: 55; makefile: 5
file content (58 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package rfc5322

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestParseFWS(t *testing.T) {
	inputs := []string{
		" \t ",
		"\r\n\t",
		" \r\n\t",
		"  \r\n  \r\n  \r\n\t",
		" \t\r\n    ",
	}

	for _, i := range inputs {
		p := newTestRFCParser(i)
		err := parseFWS(p)
		require.NoError(t, err)
	}
}

func TestParserComment(t *testing.T) {
	inputs := []string{
		"(my comment here)",
		"(my comment here )",
		"( my comment here)",
		"( my comment here )",
		"(my\r\n comment here)",
		"(my\r\n (comment) here)",
		"(\\my\r\n (comment) here)",
		"(" + string([]byte{0x7F, 0x8}) + ")",
	}

	for _, i := range inputs {
		p := newTestRFCParser(i)
		err := parseComment(p)
		require.NoError(t, err)
	}
}

func TestParserCFWS(t *testing.T) {
	inputs := []string{
		" ",
		"(my comment here)",
		" (my comment here) ",
		" \r\n (my comment here)  ",
		" \r\n \r\n (my comment here) \r\n ",
	}

	for _, i := range inputs {
		p := newTestRFCParser(i)
		err := parseCFWS(p)
		require.NoError(t, err)
	}
}