forked from gojuno/go.osrm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
options_test.go
103 lines (86 loc) · 2.26 KB
/
options_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package osrm
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestOptionBlank(t *testing.T) {
var opts options
assert.Equal(t, "", opts.encode())
}
func TestOptionSetVal(t *testing.T) {
opts := options{}
opts.set("foo", "bar")
assert.Equal(t, "foo=bar", opts.encode())
}
func TestOptionSetTwoKeys(t *testing.T) {
opts := options{}
opts.set("foo", "bar")
opts.set("baz", "quux")
assert.Equal(t, "baz=quux&foo=bar", opts.encode())
}
func TestOptionSetBool(t *testing.T) {
opts := options{}
opts.setBool("foo", true)
assert.Equal(t, "foo=true", opts.encode())
}
func TestOptionReplaceVal(t *testing.T) {
opts := options{}
opts.set("foo", "bar")
opts.set("foo", "baz")
assert.Equal(t, "foo=baz", opts.encode())
}
func TestOptionAddVal(t *testing.T) {
opts := options{}
opts.add("foo", "bar")
assert.Equal(t, "foo=bar", opts.encode())
}
func TestOptionAddTwoVals(t *testing.T) {
opts := options{}
opts.add("foo", "bar")
opts.add("foo", "baz")
assert.Equal(t, "foo=bar;baz", opts.encode())
}
func TestOptionAddTwoValsAsVariadic(t *testing.T) {
opts := options{}
opts.add("foo", "bar", "baz")
assert.Equal(t, "foo=bar;baz", opts.encode())
}
func TestOptionSetKeyAndAddTwoVals(t *testing.T) {
opts := options{}
opts.set("foo", "bar")
opts.add("baz", "quux")
opts.add("baz", "zuko")
assert.Equal(t, "baz=quux;zuko&foo=bar", opts.encode())
}
func TestOptionAddTwoValsAndSetKey(t *testing.T) {
opts := options{}
opts.add("foo", "bar")
opts.add("foo", "baz")
opts.set("quux", "zuko")
assert.Equal(t, "foo=bar;baz&quux=zuko", opts.encode())
}
func TestOptionAddIntVal(t *testing.T) {
opts := options{}
opts.addInt("foo", 1)
assert.Equal(t, "foo=1", opts.encode())
}
func TestOptionAddIntValsAsVariadic(t *testing.T) {
opts := options{}
opts.addInt("foo", 1, 2)
assert.Equal(t, "foo=1;2", opts.encode())
}
func TestOptionsAddInt64Val(t *testing.T) {
opts := options{}
opts.addInt64("foo", int64(1))
assert.Equal(t, "foo=1", opts.encode())
}
func TestOptionsAddFloatVal(t *testing.T) {
opts := options{}
opts.addFloat("foo", 0.1231)
assert.Equal(t, "foo=0.1231", opts.encode())
}
func TestOptionsAddFloatValsAsVariadic(t *testing.T) {
opts := options{}
opts.addFloat("foo", 1.1231312, 2.1233)
assert.Equal(t, "foo=1.1231312;2.1233", opts.encode())
}