forked from gammban/numtow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloat64_test.go
37 lines (32 loc) · 921 Bytes
/
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
package numtow
import (
"errors"
"strings"
"testing"
)
func TestFloat64(t *testing.T) {
for _, v := range testCaseDecimalNumbers {
gotResult, gotErr := Float64(v.GiveFloat64, v.GiveLang, v.GiveOpts...)
if !errors.Is(gotErr, v.WantErr) {
t.Errorf("%s: \nexp: '%s' \ngot: '%s'", v.GiveDecimal, v.WantErr, gotErr)
}
if gotErr == nil {
if !strings.EqualFold(gotResult, v.WantResult) {
t.Errorf("%s: \nexp: '%s' \ngot: '%s'", v.GiveDecimal, v.WantResult, gotResult)
}
}
}
}
func TestMustFloat64(t *testing.T) {
for _, v := range testCaseDecimalNumbers {
gotResult := MustFloat64(v.GiveFloat64, v.GiveLang, v.GiveOpts...)
if v.WantErr != nil && gotResult != "" {
t.Errorf("%s: expected error", v.GiveDecimal)
}
if gotResult != "" {
if !strings.EqualFold(gotResult, v.WantResult) {
t.Errorf("%s: \nexp: '%s' \ngot: '%s'", v.GiveDecimal, v.WantResult, gotResult)
}
}
}
}