mirror of
https://github.com/araddon/dateparse.git
synced 2024-09-20 19:06:34 +08:00
Test improvements.. I think
This commit is contained in:
parent
53a8cbdf09
commit
544b5426f4
@ -10,7 +10,7 @@ import (
|
||||
|
||||
func TestOne(t *testing.T) {
|
||||
time.Local = time.UTC
|
||||
var ts time.Time = MustParse("2020-07-20+08:00")
|
||||
var ts = MustParse("2020-07-20+08:00")
|
||||
assert.Equal(t, "2020-07-19 16:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||
}
|
||||
|
||||
@ -435,6 +435,12 @@ func TestParse(t *testing.T) {
|
||||
assert.NotEqual(t, nil, err)
|
||||
|
||||
for _, th := range testInputs {
|
||||
t.Run(th.in, func(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Fatalf("error: %s", r)
|
||||
}
|
||||
}()
|
||||
if len(th.loc) > 0 {
|
||||
loc, err := time.LoadLocation(th.loc)
|
||||
if err != nil {
|
||||
@ -447,16 +453,17 @@ func TestParse(t *testing.T) {
|
||||
got := fmt.Sprintf("%v", ts.In(time.UTC))
|
||||
assert.Equal(t, th.out, got, "Expected %q but got %q from %q", th.out, got, th.in)
|
||||
if th.out != got {
|
||||
panic("whoops")
|
||||
t.Fatalf("whoops, got %s, expected %s", got, th.out)
|
||||
}
|
||||
} else {
|
||||
ts = MustParse(th.in)
|
||||
got := fmt.Sprintf("%v", ts.In(time.UTC))
|
||||
assert.Equal(t, th.out, got, "Expected %q but got %q from %q", th.out, got, th.in)
|
||||
if th.out != got {
|
||||
panic("whoops")
|
||||
t.Fatalf("whoops, got %s, expected %s", got, th.out)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// some errors
|
||||
|
Loading…
Reference in New Issue
Block a user