-
Notifications
You must be signed in to change notification settings - Fork 2
/
filter_test.go
65 lines (57 loc) · 1.88 KB
/
filter_test.go
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
59
60
61
62
63
64
65
// 2019, Georg Sauthoff <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"bytes"
"testing"
)
func Test_xgonzo_filter(t *testing.T) {
var b bytes.Buffer
w := new_xgonzo_filter_writer(new_close_writer(&b))
w.Write([]byte("X-gonzo: spam"))
w.Close()
if !bytes.Equal(b.Bytes(), []byte("X-old-gonzo: spam")) {
t.Errorf("Unexpected result: |%s|", b.Bytes())
}
}
func Test_xgonzo_filter_partial(t *testing.T) {
var b bytes.Buffer
w := new_xgonzo_filter_writer(new_close_writer(&b))
w.Write([]byte("Subject: blah\nX-gonz"))
w.Write([]byte("o: spam"))
w.Close()
if !bytes.Equal(b.Bytes(), []byte("Subject: blah\nX-old-gonzo: spam")) {
t.Errorf("Unexpected result: |%s|", b.Bytes())
}
}
func Test_xgonzo_filter_partial2(t *testing.T) {
var b bytes.Buffer
w := new_xgonzo_filter_writer(new_close_writer(&b))
w.Write([]byte("Subject: blah\nX-gonz"))
w.Write([]byte(": spam"))
w.Close()
if !bytes.Equal(b.Bytes(), []byte("Subject: blah\nX-gonz: spam")) {
t.Errorf("Unexpected result: |%s|", b.Bytes())
}
}
func Test_xgonzo_filter_mult(t *testing.T) {
var b bytes.Buffer
w := new_xgonzo_filter_writer(new_close_writer(&b))
w.Write([]byte("X-gonzo: ham\nSubject: blah\nX-gonzo"))
w.Write([]byte(": spam"))
w.Close()
if !bytes.Equal(b.Bytes(),
[]byte("X-old-gonzo: ham\nSubject: blah\nX-old-gonzo: spam")) {
t.Errorf("Unexpected result: |%s|", b.Bytes())
}
}
func Test_xgonzo_filter_insensitive(t *testing.T) {
var b bytes.Buffer
w := new_xgonzo_filter_writer(new_close_writer(&b))
w.Write([]byte("x-gonzo: ham\nSubject: blah\nX-gonzo: spam"))
w.Close()
if !bytes.Equal(b.Bytes(),
[]byte("X-old-gonzo: ham\nSubject: blah\nX-old-gonzo: spam")) {
t.Errorf("Unexpected result: |%s|", b.Bytes())
}
}