-
Notifications
You must be signed in to change notification settings - Fork 0
/
properties_test.go
62 lines (49 loc) · 1.84 KB
/
properties_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
package proper
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestBooleanParam(t *testing.T) {
parameters := make(map[string]string)
parameters["boolean"] = "true"
parameters["integer"] = "1"
parameters["bad"] = "bad"
emptyProperties := &Properties{}
properties := NewProperties(parameters)
assert.Equal(t, emptyProperties.BooleanParam("boolean", false), false)
assert.Equal(t, properties.BooleanParam("boolean", false), true)
assert.Equal(t, properties.BooleanParam("integer", false), true)
assert.Equal(t, properties.BooleanParam("bad", false), false)
}
func TestFloatParam(t *testing.T) {
parameters := make(map[string]string)
parameters["integer"] = "11"
parameters["float"] = "1.2"
parameters["bad"] = "bad"
emptyProperties := &Properties{}
properties := NewProperties(parameters)
assert.Equal(t, emptyProperties.FloatParam("float", 0), float64(0))
assert.Equal(t, properties.FloatParam("integer", 0), float64(11))
assert.Equal(t, properties.FloatParam("float", 0), float64(1.2))
assert.Equal(t, properties.FloatParam("bad", 0), float64(0))
}
func TestIntegerParam(t *testing.T) {
parameters := make(map[string]string)
parameters["integer"] = "11"
parameters["float"] = "1.2"
parameters["bad"] = "bad"
emptyProperties := &Properties{}
properties := NewProperties(parameters)
assert.Equal(t, emptyProperties.IntegerParam("integer", 0), 0)
assert.Equal(t, properties.IntegerParam("integer", 0), 11)
assert.Equal(t, properties.IntegerParam("float", 0), 0)
assert.Equal(t, properties.IntegerParam("bad", 0), 0)
}
func TestStringParam(t *testing.T) {
parameters := make(map[string]string)
parameters["string"] = "value"
emptyProperties := &Properties{}
properties := NewProperties(parameters)
assert.Equal(t, emptyProperties.StringParam("string", ""), "")
assert.Equal(t, properties.StringParam("string", ""), "value")
}