forked from RambIing/urlValues
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurlValues_test.go
More file actions
46 lines (34 loc) · 820 Bytes
/
urlValues_test.go
File metadata and controls
46 lines (34 loc) · 820 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
37
38
39
40
41
42
43
44
45
46
package urlValues
import (
"testing"
)
func getValues() Values {
values := Values{}
values.Add("xyz", "abc")
values.Add("abc", "xyz")
return values
}
func TestValues_Encode(t *testing.T) {
values := getValues()
if values.Encode() != "abc=xyz&xyz=abc" {
t.FailNow()
}
values.Del("xyz")
if values.EncodeWithOrder() != "abc=xyz" {
t.Fatalf("failed to delete item")
}
}
func TestValues_EncodeWithOrder(t *testing.T) {
values := getValues()
if values.EncodeWithOrder() != "xyz=abc&abc=xyz" {
t.FailNow()
}
values[OrderKey] = []string{"abc", "xyz"}
if values.EncodeWithOrder() != "abc=xyz&xyz=abc" {
t.Fatalf("failed to manually rearrange order")
}
values.Del("abc")
if values.EncodeWithOrder() != "xyz=abc" && len(values[OrderKey]) != 1 {
t.Fatalf("failed to fully delete item")
}
}