-
Notifications
You must be signed in to change notification settings - Fork 0
/
float64_test.go
38 lines (31 loc) · 1.04 KB
/
float64_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
package confunc_test
import (
"github.com/alperkose/confunc"
"strconv"
"testing"
)
func Test_Float64Func(t *testing.T) {
expectedValue := 42.42
configurationKey := "myConfig"
configUnderTest := confunc.
From(confunc.Map(map[string]string{configurationKey: strconv.FormatFloat(expectedValue, 'f', -1, 64)})).
Float64(configurationKey)
actualValue := configUnderTest()
if actualValue != expectedValue {
t.Errorf("expected '%v' to be '%v'", actualValue, expectedValue)
}
}
func Test_Float64FuncWithInterceptor(t *testing.T) {
aValue := 42.42
expectedValue := 15.96
configurationKey := "myConfig"
configUnderTest := confunc.
From(confunc.Map(map[string]string{configurationKey: strconv.FormatFloat(aValue, 'f', -1, 64)})).
Float64(configurationKey, func(s confunc.Confunc) confunc.Confunc {
return func() (string, error) { return strconv.FormatFloat(expectedValue, 'f', -1, 64), nil }
})
actualValue := configUnderTest()
if actualValue != expectedValue {
t.Errorf("expected '%v' to be '%v'", actualValue, expectedValue)
}
}