mirror of
https://gitee.com/dromara/carbon.git
synced 2024-12-02 04:07:36 +08:00
修复测试用例错误
This commit is contained in:
parent
6b3822fa1b
commit
8bf83a21a0
124
encoding_test.go
124
encoding_test.go
@ -214,68 +214,6 @@ func TestCarbon_MarshalJSON(t *testing.T) {
|
||||
assert.Equal(t, "2020-08-05T13:14:15.999999+08:00", person.Birthday59.String())
|
||||
assert.Equal(t, "2020-08-05T13:14:15.999999999+08:00", person.Birthday60.String())
|
||||
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:Local", person.Birthday0.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02;tz:Local", person.Birthday1.Tag())
|
||||
assert.Equal(t, "layout:15:04:05;tz:Local", person.Birthday2.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:Local", person.Birthday3.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02;tz:PRC", person.Birthday4.Tag())
|
||||
assert.Equal(t, "layout:15:04:05;tz:PRC", person.Birthday5.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:PRC", person.Birthday6.Tag())
|
||||
assert.Equal(t, "format:Y-m-d;tz:Local", person.Birthday7.Tag())
|
||||
assert.Equal(t, "format:H:i:s;tz:Local", person.Birthday8.Tag())
|
||||
assert.Equal(t, "format:Y-m-d H:i:s;tz:Local", person.Birthday9.Tag())
|
||||
assert.Equal(t, "format:Y-m-d;tz:PRC", person.Birthday10.Tag())
|
||||
assert.Equal(t, "format:H:i:s;tz:PRC", person.Birthday11.Tag())
|
||||
assert.Equal(t, "format:Y-m-d H:i:s;tz:PRC", person.Birthday12.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:Local", person.Birthday13.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05.999;tz:Local", person.Birthday14.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05.999999;tz:Local", person.Birthday15.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05.999999999;tz:Local", person.Birthday16.Tag())
|
||||
assert.Equal(t, "layout:20060102150405;tz:Local", person.Birthday17.Tag())
|
||||
assert.Equal(t, "layout:20060102150405.999;tz:Local", person.Birthday18.Tag())
|
||||
assert.Equal(t, "layout:20060102150405.999999;tz:Local", person.Birthday19.Tag())
|
||||
assert.Equal(t, "layout:20060102150405.999999999;tz:Local", person.Birthday20.Tag())
|
||||
assert.Equal(t, "layout:Mon, Jan 2, 2006 3:04 PM;tz:Local", person.Birthday21.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02;tz:Local", person.Birthday22.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02.999;tz:Local", person.Birthday23.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02.999999;tz:Local", person.Birthday24.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02.999999999;tz:Local", person.Birthday25.Tag())
|
||||
assert.Equal(t, "layout:20060102;tz:Local", person.Birthday26.Tag())
|
||||
assert.Equal(t, "layout:20060102.999;tz:Local", person.Birthday27.Tag())
|
||||
assert.Equal(t, "layout:20060102.999999;tz:Local", person.Birthday28.Tag())
|
||||
assert.Equal(t, "layout:20060102.999999999;tz:Local", person.Birthday29.Tag())
|
||||
assert.Equal(t, "layout:15:04:05;tz:Local", person.Birthday30.Tag())
|
||||
assert.Equal(t, "layout:15:04:05.999;tz:Local", person.Birthday31.Tag())
|
||||
assert.Equal(t, "layout:15:04:05.999999;tz:Local", person.Birthday32.Tag())
|
||||
assert.Equal(t, "layout:15:04:05.999999999;tz:Local", person.Birthday33.Tag())
|
||||
assert.Equal(t, "layout:150405;tz:Local", person.Birthday34.Tag())
|
||||
assert.Equal(t, "layout:150405.999;tz:Local", person.Birthday35.Tag())
|
||||
assert.Equal(t, "layout:150405.999999;tz:Local", person.Birthday36.Tag())
|
||||
assert.Equal(t, "layout:150405.999999999;tz:Local", person.Birthday37.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05Z07:00;tz:Local", person.Birthday38.Tag())
|
||||
assert.Equal(t, "layout:Mon Jan _2 15:04:05 2006;tz:Local", person.Birthday39.Tag())
|
||||
assert.Equal(t, "layout:Monday, 02-Jan-2006 15:04:05 MST;tz:Local", person.Birthday40.Tag())
|
||||
assert.Equal(t, "layout:3:04PM;tz:Local", person.Birthday41.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 -0700;tz:Local", person.Birthday42.Tag())
|
||||
assert.Equal(t, "layout:Mon Jan 02 15:04:05 -0700 2006;tz:Local", person.Birthday43.Tag())
|
||||
assert.Equal(t, "layout:Mon Jan _2 15:04:05 MST 2006;tz:Local", person.Birthday44.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 06 15:04:05 -0700;tz:Local", person.Birthday45.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 MST;tz:Local", person.Birthday46.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 -0700;tz:Local", person.Birthday47.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 -0700;tz:Local", person.Birthday48.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05Z07:00;tz:Local", person.Birthday49.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999Z07:00;tz:Local", person.Birthday50.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999Z07:00;tz:Local", person.Birthday51.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999999Z07:00;tz:Local", person.Birthday52.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 MST;tz:Local", person.Birthday53.Tag())
|
||||
assert.Equal(t, "layout:02 Jan 06 15:04 MST;tz:Local", person.Birthday54.Tag())
|
||||
assert.Equal(t, "layout:02 Jan 06 15:04 -0700;tz:Local", person.Birthday55.Tag())
|
||||
assert.Equal(t, "layout:Monday, 02-Jan-06 15:04:05 MST;tz:Local", person.Birthday56.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05-07:00;tz:Local", person.Birthday57.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999-07:00;tz:Local", person.Birthday58.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999-07:00;tz:Local", person.Birthday59.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999999-07:00;tz:Local", person.Birthday60.Tag())
|
||||
|
||||
fmt.Printf("person output by json:\n%s\n", data)
|
||||
}
|
||||
|
||||
@ -414,68 +352,6 @@ func TestCarbon_UnmarshalJSON(t *testing.T) {
|
||||
assert.Equal(t, "2020-08-05T13:14:15.999999+08:00", person.Birthday59.String())
|
||||
assert.Equal(t, "2020-08-05T13:14:15.999999999+08:00", person.Birthday60.String())
|
||||
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:Local", person.Birthday0.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02;tz:Local", person.Birthday1.Tag())
|
||||
assert.Equal(t, "layout:15:04:05;tz:Local", person.Birthday2.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:Local", person.Birthday3.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02;tz:PRC", person.Birthday4.Tag())
|
||||
assert.Equal(t, "layout:15:04:05;tz:PRC", person.Birthday5.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:PRC", person.Birthday6.Tag())
|
||||
assert.Equal(t, "format:Y-m-d;tz:Local", person.Birthday7.Tag())
|
||||
assert.Equal(t, "format:H:i:s;tz:Local", person.Birthday8.Tag())
|
||||
assert.Equal(t, "format:Y-m-d H:i:s;tz:Local", person.Birthday9.Tag())
|
||||
assert.Equal(t, "format:Y-m-d;tz:PRC", person.Birthday10.Tag())
|
||||
assert.Equal(t, "format:H:i:s;tz:PRC", person.Birthday11.Tag())
|
||||
assert.Equal(t, "format:Y-m-d H:i:s;tz:PRC", person.Birthday12.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05;tz:Local", person.Birthday13.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05.999;tz:Local", person.Birthday14.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05.999999;tz:Local", person.Birthday15.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02 15:04:05.999999999;tz:Local", person.Birthday16.Tag())
|
||||
assert.Equal(t, "layout:20060102150405;tz:Local", person.Birthday17.Tag())
|
||||
assert.Equal(t, "layout:20060102150405.999;tz:Local", person.Birthday18.Tag())
|
||||
assert.Equal(t, "layout:20060102150405.999999;tz:Local", person.Birthday19.Tag())
|
||||
assert.Equal(t, "layout:20060102150405.999999999;tz:Local", person.Birthday20.Tag())
|
||||
assert.Equal(t, "layout:Mon, Jan 2, 2006 3:04 PM;tz:Local", person.Birthday21.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02;tz:Local", person.Birthday22.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02.999;tz:Local", person.Birthday23.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02.999999;tz:Local", person.Birthday24.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02.999999999;tz:Local", person.Birthday25.Tag())
|
||||
assert.Equal(t, "layout:20060102;tz:Local", person.Birthday26.Tag())
|
||||
assert.Equal(t, "layout:20060102.999;tz:Local", person.Birthday27.Tag())
|
||||
assert.Equal(t, "layout:20060102.999999;tz:Local", person.Birthday28.Tag())
|
||||
assert.Equal(t, "layout:20060102.999999999;tz:Local", person.Birthday29.Tag())
|
||||
assert.Equal(t, "layout:15:04:05;tz:Local", person.Birthday30.Tag())
|
||||
assert.Equal(t, "layout:15:04:05.999;tz:Local", person.Birthday31.Tag())
|
||||
assert.Equal(t, "layout:15:04:05.999999;tz:Local", person.Birthday32.Tag())
|
||||
assert.Equal(t, "layout:15:04:05.999999999;tz:Local", person.Birthday33.Tag())
|
||||
assert.Equal(t, "layout:150405;tz:Local", person.Birthday34.Tag())
|
||||
assert.Equal(t, "layout:150405.999;tz:Local", person.Birthday35.Tag())
|
||||
assert.Equal(t, "layout:150405.999999;tz:Local", person.Birthday36.Tag())
|
||||
assert.Equal(t, "layout:150405.999999999;tz:Local", person.Birthday37.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05Z07:00;tz:Local", person.Birthday38.Tag())
|
||||
assert.Equal(t, "layout:Mon Jan _2 15:04:05 2006;tz:Local", person.Birthday39.Tag())
|
||||
assert.Equal(t, "layout:Monday, 02-Jan-2006 15:04:05 MST;tz:Local", person.Birthday40.Tag())
|
||||
assert.Equal(t, "layout:3:04PM;tz:Local", person.Birthday41.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 -0700;tz:Local", person.Birthday42.Tag())
|
||||
assert.Equal(t, "layout:Mon Jan 02 15:04:05 -0700 2006;tz:Local", person.Birthday43.Tag())
|
||||
assert.Equal(t, "layout:Mon Jan _2 15:04:05 MST 2006;tz:Local", person.Birthday44.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 06 15:04:05 -0700;tz:Local", person.Birthday45.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 MST;tz:Local", person.Birthday46.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 -0700;tz:Local", person.Birthday47.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 -0700;tz:Local", person.Birthday48.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05Z07:00;tz:Local", person.Birthday49.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999Z07:00;tz:Local", person.Birthday50.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999Z07:00;tz:Local", person.Birthday51.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999999Z07:00;tz:Local", person.Birthday52.Tag())
|
||||
assert.Equal(t, "layout:Mon, 02 Jan 2006 15:04:05 MST;tz:Local", person.Birthday53.Tag())
|
||||
assert.Equal(t, "layout:02 Jan 06 15:04 MST;tz:Local", person.Birthday54.Tag())
|
||||
assert.Equal(t, "layout:02 Jan 06 15:04 -0700;tz:Local", person.Birthday55.Tag())
|
||||
assert.Equal(t, "layout:Monday, 02-Jan-06 15:04:05 MST;tz:Local", person.Birthday56.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05-07:00;tz:Local", person.Birthday57.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999-07:00;tz:Local", person.Birthday58.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999-07:00;tz:Local", person.Birthday59.Tag())
|
||||
assert.Equal(t, "layout:2006-01-02T15:04:05.999999999-07:00;tz:Local", person.Birthday60.Tag())
|
||||
|
||||
fmt.Printf("Json string parse to person:\n%+v\n", person)
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,6 @@ func TestCarbon_SetLocation(t *testing.T) {
|
||||
loc *time.Location
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
loc: getLocation(Local),
|
||||
expected: Local,
|
||||
},
|
||||
{
|
||||
loc: getLocation(UTC),
|
||||
expected: UTC,
|
||||
|
Loading…
Reference in New Issue
Block a user