-
Notifications
You must be signed in to change notification settings - Fork 14
/
decoder_line_test.go
57 lines (51 loc) · 1.46 KB
/
decoder_line_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
package goics_test
import (
//"strings"
"testing"
goics "github.com/jordic/goics"
)
var TLines = []string{
"BEGIN:VEVENT",
`ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT:mailto:[email protected]`,
`X-FOO;BAR=";hidden=value";FOO=baz:realvalue`,
`ATTENDEE;ROLE="REQ-PARTICIPANT;foo";PARTSTAT=ACCEPTED;RSVP=TRUE:mailto:[email protected]`,
}
func TestDecodeLine(t *testing.T) {
node := goics.DecodeLine(TLines[0])
if node.Key != "BEGIN" {
t.Errorf("Wrong key parsing %s", node.Key)
}
if node.Val != "VEVENT" {
t.Errorf("Wrong key parsing %s", node.Key)
}
if node.ParamsLen() != 0 {
t.Error("No keys")
}
node = goics.DecodeLine(TLines[1])
if node.Key != "ATTENDEE" {
t.Errorf("Wrong key parsing %s", node.Key)
}
if node.Val != "mailto:[email protected]" {
t.Errorf("Wrong val parsing %s", node.Val)
}
if node.ParamsLen() != 2 {
t.Errorf("Wrong nmber of params %d", node.ParamsLen())
}
node = goics.DecodeLine(TLines[2])
if node.Key != "X-FOO" {
t.Errorf("Wrong key parsing %s", node.Key)
}
if node.ParamsLen() != 2 {
t.Errorf("Incorrect quoted params count %d, %v", node.ParamsLen(), node.Params)
}
node = goics.DecodeLine(TLines[3])
if node.Key != "ATTENDEE" {
t.Errorf("Wrong key parsing %s", node.Key)
}
if node.ParamsLen() != 3 {
t.Errorf("Incorrect quoted params count %d, %v", node.ParamsLen(), node.Params)
}
if node.Params["ROLE"] != "REQ-PARTICIPANT;foo" {
t.Errorf("Error extracting quoted params from line %s", node.Params["ROLE"])
}
}