forked from SebastiaanKlippert/go-foxpro-dbf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cast_test.go
61 lines (54 loc) · 1.4 KB
/
cast_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
package dbf
import (
"testing"
"time"
)
func TestToFloat64(t *testing.T) {
if ToFloat64(123.456) != float64(123.456) {
t.Errorf("Want %f, have %f", float64(123.456), ToFloat64(123.456))
}
if ToFloat64("123.456") != float64(0) {
t.Errorf("Want %f, have %f", 0.0, ToFloat64(123.456))
}
}
func TestToInt64(t *testing.T) {
if ToInt64(int64(123456)) != int64(123456) {
t.Errorf("Want %d, have %d", int64(123456), ToInt64(123456))
}
if ToInt64("123.456") != int64(0) {
t.Errorf("Want %d, have %d", 0, ToInt64(123456))
}
}
func TestToString(t *testing.T) {
if ToString("Hêllo!") != "Hêllo!" {
t.Errorf("Want %q, have %q", "Hêllo!", ToString("Hêllo!"))
}
if ToString(123.456) != "" {
t.Errorf("Want %q, have %q", "", ToString(123.456))
}
}
func TestToTrimmedString(t *testing.T) {
if ToTrimmedString("Hêllo! ") != "Hêllo!" {
t.Errorf("Want %q, have %q", "Hêllo!", ToTrimmedString("Hêllo! "))
}
if ToTrimmedString(123.456) != "" {
t.Errorf("Want %q, have %q", "", ToTrimmedString(123.456))
}
}
func TestToTime(t *testing.T) {
now := time.Now()
if ToTime(now).Equal(now) == false {
t.Errorf("Want %v, have %v", now, ToTime(now))
}
if ToTime("123.456").IsZero() == false {
t.Errorf("Want %v, have %v", time.Time{}, ToTime("123.456"))
}
}
func TestToBool(t *testing.T) {
if ToBool(true) == false {
t.Error("Want true")
}
if ToBool(33) != false {
t.Error("Want false")
}
}