-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathencode_test.go
More file actions
36 lines (27 loc) · 664 Bytes
/
encode_test.go
File metadata and controls
36 lines (27 loc) · 664 Bytes
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
package httpsfv
import (
"testing"
"time"
)
func TestMarshal(t *testing.T) {
t.Parallel()
i := NewItem(22.1)
i.Params.Add("foo", true)
i.Params.Add("bar", Token("baz"))
d := NewDictionary()
d.Add("i", i)
tok := NewItem(Token("foo"))
tok.Params.Add("a", "b")
d.Add("tok", tok)
date := NewItem(time.Date(1988, 21, 01, 0, 0, 0, 0, time.UTC))
d.Add("d", date)
if res, _ := Marshal(d); res != `i=22.1;foo;bar=baz, tok=foo;a="b", d=@620611200` {
t.Errorf("marshal: bad result: %q", res)
}
}
func TestMarshalError(t *testing.T) {
t.Parallel()
if _, err := Marshal(NewItem(Token("à"))); err == nil {
t.Errorf("marshal: error expected")
}
}