-
Notifications
You must be signed in to change notification settings - Fork 0
/
headers_test.go
41 lines (35 loc) · 998 Bytes
/
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
package stompy
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
//encoded key decoded value
var testEncodeData = map[string]string{
"astring": "astring",
"\\\\": "\\",
"\\n": "\n",
"\\c": ":",
"\\\\\\n\\c": "\\\n:",
"\\c\\n\\\\": ":\n\\",
"\\\\\\c": "\\:",
"c\\cc": "c:c",
"n\\nn": "n\nn",
"test\\cvalue\\ntest": "test:value\ntest",
}
func TestHeaders_encode(t *testing.T) {
encoder := headerEncoderDecoder{"1.1"}
for to, from := range testEncodeData {
fmt.Println("encoding from ", from, "to", to)
enc := encoder.Encode(from)
assert.Equal(t, to, enc, "expected encoded value")
}
}
func TestHeaders_decode(t *testing.T) {
decoder := headerEncoderDecoder{"1.1"}
for to, from := range testEncodeData {
fmt.Println("decoding from ", from, "to", to)
enc := decoder.Decode(to)
assert.Equal(t, from, enc, "expected encoded value")
}
}