-
Notifications
You must be signed in to change notification settings - Fork 0
/
headers_test.go
60 lines (57 loc) · 1.27 KB
/
headers_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
package main
import (
"reflect"
"testing"
)
func Test_getHeaderTermination(t *testing.T) {
tests := []struct {
name string
args []byte
want []byte
}{
{
name: "it returns remaining body read",
args: []byte{2, 13, 10, 13, 10, 30, 20, 10},
want: []byte{30, 20, 10},
},
{
name: "it returns empty slice when no over-read",
args: []byte{2, 13, 10, 13, 10},
want: []byte{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := getHeaderTermination(tt.args); !reflect.DeepEqual(got, tt.want) {
t.Errorf("getHeaderTermination() = %v, want %v", got, tt.want)
}
})
}
t.Run("it panics when no \\r\\n can be found", func(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("getHeaderTermination() did not panic on index out of range")
}
}()
getHeaderTermination([]byte{2, 10, 10, 20, 10})
})
}
func Test_parseHeaders(t *testing.T) {
type args struct {
headers []byte
}
tests := []struct {
name string
args args
want map[string]string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := parseHeaders(tt.args.headers); !reflect.DeepEqual(got, tt.want) {
t.Errorf("parseHeaders() = %v, want %v", got, tt.want)
}
})
}
}