-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzone_test.go
More file actions
58 lines (50 loc) · 1.57 KB
/
zone_test.go
File metadata and controls
58 lines (50 loc) · 1.57 KB
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
package timezone
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_00_SetZoneByName(t *testing.T) {
t.Logf("timezone.GetZoneLocal().String() %v", GetZoneLocal().String())
err := SetZoneByName(ZoneAsiaShanghai)
if err != nil {
t.Errorf("SetZoneByName err %v", err)
}
t.Logf("now: timezone.GetZoneLocal().String() %v", GetZoneLocal())
assert.Equal(t, zoneLocal, GetZoneLocal())
err = SetZoneByName("error")
t.Logf("must error: %v", err)
assert.NotEmpty(t, err)
err = SetZoneByName(ZoneGMT)
if err != nil {
t.Errorf("SetZoneByName err %v", err)
}
assert.Equal(t, ZoneGMT, GetZoneLocal().String())
err = SetZoneByName(ZoneCET)
if err != nil {
t.Errorf("SetZoneByName err %v", err)
}
assert.Equal(t, ZoneCET, GetZoneLocal().String())
err = SetZoneByName(ZoneCEST)
if err == nil {
t.Logf("SetZoneByName time.ZoneCEST must: err %v", err)
}
assert.NotEmpty(t, err)
}
func Test_01_SetZoneFix(t *testing.T) {
t.Logf("timezone.GetZoneLocal().String() %v", GetZoneLocal().String())
zoneCST := ZoneCST
SetZoneFix(zoneCST, 8)
assert.Equal(t, zoneCST, GetZoneLocal().String())
}
func Test_02_SetZoneUTC(t *testing.T) {
t.Logf("timezone.GetZoneLocal().String() %v", GetZoneLocal().String())
SetZoneUTC()
nowZone := GetZoneLocal().String()
t.Logf("timezone.GetZoneLocal().String() %v", nowZone)
assert.Equal(t, ZoneUTC, GetZoneLocal().String())
}
func Test_03_SetZoneLocation(t *testing.T) {
t.Logf("timezone.GetZoneLocal().String() %v", GetZoneLocal().String())
SetZoneLocation()
t.Logf("timezone.GetZoneLocal().String() %v", GetZoneLocal().String())
}