使用github.com/stretchr/testify/assert库替代原生testing库

This commit is contained in:
gouguoyin 2021-07-19 14:33:53 +08:00
parent 40f67c6eff
commit 79231528e4
3 changed files with 1009 additions and 921 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
package carbon
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
@ -10,15 +11,16 @@ func TestLanguage_SetLocale(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output error // 期望输出值
}{
{"en", nil},
{"zh-CN", nil},
{1, "en", nil},
{2, "zh-CN", nil},
}
for _, test := range tests {
assert.ErrorIs(NewLanguage().SetLocale(test.input), test.output)
assert.ErrorIs(NewLanguage().SetLocale(test.input), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -26,14 +28,15 @@ func TestLanguage_SetDir(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output error // 期望输出值
}{
{"lang", nil},
{1, "lang", nil},
}
for _, test := range tests {
assert.ErrorIs(NewLanguage().SetDir(test.input), test.output)
assert.ErrorIs(NewLanguage().SetDir(test.input), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -59,30 +62,31 @@ func TestLanguage_SetResources1(t *testing.T) {
lang.SetResources(resources)
tests := []struct {
id int // 测试id
input Carbon // 输入值
output string // 期望输出值
}{
{Now(), "just now"},
{Now().AddYears(1), "in 1 yr"},
{Now().SubYears(1), "1 yr ago"},
{Now().AddYears(10), "in 10 yrs"},
{Now().SubYears(10), "10 yrs ago"},
{1, Now(), "just now"},
{2, Now().AddYears(1), "in 1 yr"},
{3, Now().SubYears(1), "1 yr ago"},
{4, Now().AddYears(10), "in 10 yrs"},
{5, Now().SubYears(10), "10 yrs ago"},
{Now().AddMonths(1), "in 1 mo"},
{Now().SubMonths(1), "1 mo ago"},
{Now().AddMonths(10), "in 10 mos"},
{Now().SubMonths(10), "10 mos ago"},
{6, Now().AddMonths(1), "in 1 mo"},
{7, Now().SubMonths(1), "1 mo ago"},
{8, Now().AddMonths(10), "in 10 mos"},
{9, Now().SubMonths(10), "10 mos ago"},
{Now().AddDays(1), "in 1d"},
{Now().SubDays(1), "1d ago"},
{Now().AddDays(10), "in 1w"},
{Now().SubDays(10), "1w ago"},
{10, Now().AddDays(1), "in 1d"},
{11, Now().SubDays(1), "1d ago"},
{12, Now().AddDays(10), "in 1w"},
{13, Now().SubDays(10), "1w ago"},
}
for _, test := range tests {
c := test.input.SetLanguage(lang)
assert.Nil(c.Error)
assert.Equal(c.DiffForHumans(), test.output)
assert.Equal(c.DiffForHumans(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -96,43 +100,44 @@ func TestLanguage_SetResources2(t *testing.T) {
lang.SetResources(resources)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2021-08-05 13:14:15", ""},
{5, "0000-00-00 00:00:00", ""},
{6, "2021-08-05 13:14:15", ""},
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).DiffForHumans(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).DiffForHumans(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).Constellation(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).Constellation(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).Season(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).Season(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).ToWeekString(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).ToWeekString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).ToShortWeekString(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).ToShortWeekString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).ToMonthString(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).ToMonthString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
for _, test := range tests {
assert.Equal(Parse(test.input).SetLanguage(lang).ToShortMonthString(), test.output)
assert.Equal(Parse(test.input).SetLanguage(lang).ToShortMonthString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}

View File

@ -1,6 +1,7 @@
package carbon
import (
"strconv"
"testing"
"time"
@ -11,26 +12,27 @@ func TestCarbon_StartOfCentury(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2000-01-01 00:00:00"},
{"2020-01-31 23:59:59", "2000-01-01 00:00:00"},
{"2020-02-01 13:14:15", "2000-01-01 00:00:00"},
{"2020-02-28", "2000-01-01 00:00:00"},
{"2020-02-29", "2000-01-01 00:00:00"},
{6, "2020-01-01 00:00:00", "2000-01-01 00:00:00"},
{7, "2020-01-31 23:59:59", "2000-01-01 00:00:00"},
{8, "2020-02-01 13:14:15", "2000-01-01 00:00:00"},
{9, "2020-02-28", "2000-01-01 00:00:00"},
{10, "2020-02-29", "2000-01-01 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfCentury()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -38,26 +40,27 @@ func TestCarbon_EndOfCentury(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2999-12-31 23:59:59"},
{"2020-01-31 23:59:59", "2999-12-31 23:59:59"},
{"2020-02-01 13:14:15", "2999-12-31 23:59:59"},
{"2020-02-28", "2999-12-31 23:59:59"},
{"2020-02-29", "2999-12-31 23:59:59"},
{6, "2020-01-01 00:00:00", "2999-12-31 23:59:59"},
{7, "2020-01-31 23:59:59", "2999-12-31 23:59:59"},
{8, "2020-02-01 13:14:15", "2999-12-31 23:59:59"},
{9, "2020-02-28", "2999-12-31 23:59:59"},
{10, "2020-02-29", "2999-12-31 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfCentury()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -65,27 +68,28 @@ func TestCarbon_StartOfDecade(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-31 23:59:59", "2020-01-01 00:00:00"},
{"2021-01-01 00:00:00", "2020-01-01 00:00:00"},
{"2029-01-31 23:59:59", "2020-01-01 00:00:00"},
{"2020-02-01 13:14:15", "2020-01-01 00:00:00"},
{"2020-02-28", "2020-01-01 00:00:00"},
{"2020-02-29", "2020-01-01 00:00:00"},
{6, "2020-01-31 23:59:59", "2020-01-01 00:00:00"},
{7, "2021-01-01 00:00:00", "2020-01-01 00:00:00"},
{8, "2029-01-31 23:59:59", "2020-01-01 00:00:00"},
{9, "2020-02-01 13:14:15", "2020-01-01 00:00:00"},
{10, "2020-02-28", "2020-01-01 00:00:00"},
{11, "2020-02-29", "2020-01-01 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfDecade()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -93,27 +97,28 @@ func TestCarbon_EndOfDecade(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-31 23:59:59", "2029-12-31 23:59:59"},
{"2021-01-01 00:00:00", "2029-12-31 23:59:59"},
{"2029-01-31 23:59:59", "2029-12-31 23:59:59"},
{"2020-02-01 13:14:15", "2029-12-31 23:59:59"},
{"2020-02-28", "2029-12-31 23:59:59"},
{"2020-02-29", "2029-12-31 23:59:59"},
{6, "2020-01-31 23:59:59", "2029-12-31 23:59:59"},
{7, "2021-01-01 00:00:00", "2029-12-31 23:59:59"},
{8, "2029-01-31 23:59:59", "2029-12-31 23:59:59"},
{9, "2020-02-01 13:14:15", "2029-12-31 23:59:59"},
{10, "2020-02-28", "2029-12-31 23:59:59"},
{11, "2020-02-29", "2029-12-31 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfDecade()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -121,26 +126,27 @@ func TestCarbon_StartOfYear(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2020-01-01 00:00:00"},
{"2020-01-31 23:59:59", "2020-01-01 00:00:00"},
{"2020-02-01 13:14:15", "2020-01-01 00:00:00"},
{"2020-02-28", "2020-01-01 00:00:00"},
{"2020-02-29", "2020-01-01 00:00:00"},
{6, "2020-01-01 00:00:00", "2020-01-01 00:00:00"},
{7, "2020-01-31 23:59:59", "2020-01-01 00:00:00"},
{8, "2020-02-01 13:14:15", "2020-01-01 00:00:00"},
{9, "2020-02-28", "2020-01-01 00:00:00"},
{10, "2020-02-29", "2020-01-01 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfYear()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -148,26 +154,27 @@ func TestCarbon_EndOfYear(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2020-12-31 23:59:59"},
{"2020-01-31 23:59:59", "2020-12-31 23:59:59"},
{"2020-02-01 13:14:15", "2020-12-31 23:59:59"},
{"2020-02-28", "2020-12-31 23:59:59"},
{"2020-02-29", "2020-12-31 23:59:59"},
{6, "2020-01-01 00:00:00", "2020-12-31 23:59:59"},
{7, "2020-01-31 23:59:59", "2020-12-31 23:59:59"},
{8, "2020-02-01 13:14:15", "2020-12-31 23:59:59"},
{9, "2020-02-28", "2020-12-31 23:59:59"},
{10, "2020-02-29", "2020-12-31 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfYear()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -175,33 +182,34 @@ func TestCarbon_StartOfQuarter(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-02-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-03-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-05-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-06-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-07-15 23:59:59", "2020-07-01 00:00:00"},
{"2020-08-15 13:14:15", "2020-07-01 00:00:00"},
{"2020-09-15 13:14:15", "2020-07-01 00:00:00"},
{"2020-10-15", "2020-10-01 00:00:00"},
{"2020-11-15", "2020-10-01 00:00:00"},
{"2020-12-15", "2020-10-01 00:00:00"},
{6, "2020-01-15 00:00:00", "2020-01-01 00:00:00"},
{7, "2020-02-15 00:00:00", "2020-01-01 00:00:00"},
{8, "2020-03-15 00:00:00", "2020-01-01 00:00:00"},
{9, "2020-04-15 23:59:59", "2020-04-01 00:00:00"},
{10, "2020-05-15 23:59:59", "2020-04-01 00:00:00"},
{11, "2020-06-15 23:59:59", "2020-04-01 00:00:00"},
{12, "2020-07-15 23:59:59", "2020-07-01 00:00:00"},
{13, "2020-08-15 13:14:15", "2020-07-01 00:00:00"},
{14, "2020-09-15 13:14:15", "2020-07-01 00:00:00"},
{15, "2020-10-15", "2020-10-01 00:00:00"},
{16, "2020-11-15", "2020-10-01 00:00:00"},
{17, "2020-12-15", "2020-10-01 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfQuarter()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -209,33 +217,34 @@ func TestCarbon_EndOfQuarter(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-02-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-03-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-04-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-05-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-07-15 23:59:59", "2020-09-30 23:59:59"},
{"2020-08-15 13:14:15", "2020-09-30 23:59:59"},
{"2020-09-15 13:14:15", "2020-09-30 23:59:59"},
{"2020-10-15", "2020-12-31 23:59:59"},
{"2020-11-15", "2020-12-31 23:59:59"},
{"2020-12-15", "2020-12-31 23:59:59"},
{6, "2020-01-15 00:00:00", "2020-03-31 23:59:59"},
{7, "2020-02-15 00:00:00", "2020-03-31 23:59:59"},
{8, "2020-03-15 00:00:00", "2020-03-31 23:59:59"},
{9, "2020-04-15 23:59:59", "2020-06-30 23:59:59"},
{10, "2020-05-15 23:59:59", "2020-06-30 23:59:59"},
{11, "2020-06-15 23:59:59", "2020-06-30 23:59:59"},
{12, "2020-07-15 23:59:59", "2020-09-30 23:59:59"},
{13, "2020-08-15 13:14:15", "2020-09-30 23:59:59"},
{14, "2020-09-15 13:14:15", "2020-09-30 23:59:59"},
{15, "2020-10-15", "2020-12-31 23:59:59"},
{16, "2020-11-15", "2020-12-31 23:59:59"},
{17, "2020-12-15", "2020-12-31 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfQuarter()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -243,33 +252,34 @@ func TestCarbon_StartOfMonth(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-01 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-01 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-05-15 23:59:59", "2020-05-01 00:00:00"},
{"2020-06-15 23:59:59", "2020-06-01 00:00:00"},
{"2020-07-15 23:59:59", "2020-07-01 00:00:00"},
{"2020-08-15 13:14:15", "2020-08-01 00:00:00"},
{"2020-09-15 13:14:15", "2020-09-01 00:00:00"},
{"2020-10-15", "2020-10-01 00:00:00"},
{"2020-11-15", "2020-11-01 00:00:00"},
{"2020-12-15", "2020-12-01 00:00:00"},
{6, "2020-01-15 00:00:00", "2020-01-01 00:00:00"},
{7, "2020-02-15 00:00:00", "2020-02-01 00:00:00"},
{8, "2020-03-15 00:00:00", "2020-03-01 00:00:00"},
{9, "2020-04-15 23:59:59", "2020-04-01 00:00:00"},
{10, "2020-05-15 23:59:59", "2020-05-01 00:00:00"},
{11, "2020-06-15 23:59:59", "2020-06-01 00:00:00"},
{12, "2020-07-15 23:59:59", "2020-07-01 00:00:00"},
{13, "2020-08-15 13:14:15", "2020-08-01 00:00:00"},
{14, "2020-09-15 13:14:15", "2020-09-01 00:00:00"},
{15, "2020-10-15", "2020-10-01 00:00:00"},
{16, "2020-11-15", "2020-11-01 00:00:00"},
{17, "2020-12-15", "2020-12-01 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfMonth()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -277,33 +287,34 @@ func TestCarbon_EndOfMonth(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-31 23:59:59"},
{"2020-02-15 00:00:00", "2020-02-29 23:59:59"},
{"2020-03-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-04-15 23:59:59", "2020-04-30 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-31 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-31 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-31 23:59:59"},
{"2020-09-15 13:14:15", "2020-09-30 23:59:59"},
{"2020-10-15", "2020-10-31 23:59:59"},
{"2020-11-15", "2020-11-30 23:59:59"},
{"2020-12-15", "2020-12-31 23:59:59"},
{6, "2020-01-15 00:00:00", "2020-01-31 23:59:59"},
{7, "2020-02-15 00:00:00", "2020-02-29 23:59:59"},
{8, "2020-03-15 00:00:00", "2020-03-31 23:59:59"},
{9, "2020-04-15 23:59:59", "2020-04-30 23:59:59"},
{10, "2020-05-15 23:59:59", "2020-05-31 23:59:59"},
{11, "2020-06-15 23:59:59", "2020-06-30 23:59:59"},
{12, "2020-07-15 23:59:59", "2020-07-31 23:59:59"},
{13, "2020-08-15 13:14:15", "2020-08-31 23:59:59"},
{14, "2020-09-15 13:14:15", "2020-09-30 23:59:59"},
{15, "2020-10-15", "2020-10-31 23:59:59"},
{16, "2020-11-15", "2020-11-30 23:59:59"},
{17, "2020-12-15", "2020-12-31 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfMonth()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -311,29 +322,30 @@ func TestCarbon_StartOfWeek(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
week time.Weekday // 输入参数
output string // 期望输出值
}{
{"", time.Sunday, ""},
{"0000-00-00 00:00:00", time.Sunday, ""},
{"", time.Monday, ""},
{"0000-00-00 00:00:00", time.Monday, ""},
{1, "", time.Sunday, ""},
{2, "0000-00-00 00:00:00", time.Sunday, ""},
{3, "", time.Monday, ""},
{4, "0000-00-00 00:00:00", time.Monday, ""},
{"2021-06-13", time.Sunday, "2021-06-13 00:00:00"},
{"2021-06-14", time.Sunday, "2021-06-13 00:00:00"},
{"2021-06-18", time.Sunday, "2021-06-13 00:00:00"},
{"2021-06-13", time.Monday, "2021-06-07 00:00:00"},
{"2021-06-14", time.Monday, "2021-06-14 00:00:00"},
{"2021-06-18", time.Monday, "2021-06-14 00:00:00"},
{"2021-06-19", time.Monday, "2021-06-14 00:00:00"},
{"2021-06-20", time.Monday, "2021-06-14 00:00:00"},
{5, "2021-06-13", time.Sunday, "2021-06-13 00:00:00"},
{6, "2021-06-14", time.Sunday, "2021-06-13 00:00:00"},
{7, "2021-06-18", time.Sunday, "2021-06-13 00:00:00"},
{8, "2021-06-13", time.Monday, "2021-06-07 00:00:00"},
{9, "2021-06-14", time.Monday, "2021-06-14 00:00:00"},
{10, "2021-06-18", time.Monday, "2021-06-14 00:00:00"},
{11, "2021-06-19", time.Monday, "2021-06-14 00:00:00"},
{12, "2021-06-20", time.Monday, "2021-06-14 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfWeek(test.week)
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -341,32 +353,33 @@ func TestCarbon_EndOfWeek(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
week time.Weekday // 输入参数
output string // 期望输出值
}{
{"", time.Sunday, ""},
{"0000-00-00 00:00:00", time.Sunday, ""},
{"", time.Monday, ""},
{"0000-00-00 00:00:00", time.Monday, ""},
{1, "", time.Sunday, ""},
{2, "0000-00-00 00:00:00", time.Sunday, ""},
{3, "", time.Monday, ""},
{4, "0000-00-00 00:00:00", time.Monday, ""},
{"2021-06-13", time.Sunday, "2021-06-19 23:59:59"},
{"2021-06-14", time.Sunday, "2021-06-19 23:59:59"},
{"2021-06-18", time.Sunday, "2021-06-19 23:59:59"},
{"2021-07-17", time.Sunday, "2021-07-17 23:59:59"},
{"2021-07-18", time.Sunday, "2021-07-24 23:59:59"},
{"2021-06-13", time.Monday, "2021-06-13 23:59:59"},
{"2021-06-14", time.Monday, "2021-06-20 23:59:59"},
{"2021-06-18", time.Monday, "2021-06-20 23:59:59"},
{"2021-06-19", time.Monday, "2021-06-20 23:59:59"},
{"2021-07-17", time.Monday, "2021-07-18 23:59:59"},
{"2021-07-18", time.Monday, "2021-07-18 23:59:59"},
{5, "2021-06-13", time.Sunday, "2021-06-19 23:59:59"},
{6, "2021-06-14", time.Sunday, "2021-06-19 23:59:59"},
{7, "2021-06-18", time.Sunday, "2021-06-19 23:59:59"},
{8, "2021-07-17", time.Sunday, "2021-07-17 23:59:59"},
{9, "2021-07-18", time.Sunday, "2021-07-24 23:59:59"},
{10, "2021-06-13", time.Monday, "2021-06-13 23:59:59"},
{11, "2021-06-14", time.Monday, "2021-06-20 23:59:59"},
{12, "2021-06-18", time.Monday, "2021-06-20 23:59:59"},
{13, "2021-06-19", time.Monday, "2021-06-20 23:59:59"},
{14, "2021-07-17", time.Monday, "2021-07-18 23:59:59"},
{15, "2021-07-18", time.Monday, "2021-07-18 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfWeek(test.week)
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -374,33 +387,34 @@ func TestCarbon_StartOfDay(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-15 00:00:00"},
{"2020-05-15 23:59:59", "2020-05-15 00:00:00"},
{"2020-06-15 23:59:59", "2020-06-15 00:00:00"},
{"2020-07-15 23:59:59", "2020-07-15 00:00:00"},
{"2020-08-15 13:14:15", "2020-08-15 00:00:00"},
{"2020-09-15 13:14:15", "2020-09-15 00:00:00"},
{"2020-10-15", "2020-10-15 00:00:00"},
{"2020-11-15", "2020-11-15 00:00:00"},
{"2020-12-15", "2020-12-15 00:00:00"},
{6, "2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{7, "2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{8, "2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{9, "2020-04-15 23:59:59", "2020-04-15 00:00:00"},
{10, "2020-05-15 23:59:59", "2020-05-15 00:00:00"},
{11, "2020-06-15 23:59:59", "2020-06-15 00:00:00"},
{12, "2020-07-15 23:59:59", "2020-07-15 00:00:00"},
{13, "2020-08-15 13:14:15", "2020-08-15 00:00:00"},
{14, "2020-09-15 13:14:15", "2020-09-15 00:00:00"},
{15, "2020-10-15", "2020-10-15 00:00:00"},
{16, "2020-11-15", "2020-11-15 00:00:00"},
{17, "2020-12-15", "2020-12-15 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfDay()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -408,33 +422,34 @@ func TestCarbon_EndOfDay(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 23:59:59"},
{"2020-02-15 00:00:00", "2020-02-15 23:59:59"},
{"2020-03-15 00:00:00", "2020-03-15 23:59:59"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-15 23:59:59"},
{"2020-09-15 13:14:15", "2020-09-15 23:59:59"},
{"2020-10-15", "2020-10-15 23:59:59"},
{"2020-11-15", "2020-11-15 23:59:59"},
{"2020-12-15", "2020-12-15 23:59:59"},
{6, "2020-01-15 00:00:00", "2020-01-15 23:59:59"},
{7, "2020-02-15 00:00:00", "2020-02-15 23:59:59"},
{8, "2020-03-15 00:00:00", "2020-03-15 23:59:59"},
{9, "2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{10, "2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{11, "2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{12, "2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{13, "2020-08-15 13:14:15", "2020-08-15 23:59:59"},
{14, "2020-09-15 13:14:15", "2020-09-15 23:59:59"},
{15, "2020-10-15", "2020-10-15 23:59:59"},
{16, "2020-11-15", "2020-11-15 23:59:59"},
{17, "2020-12-15", "2020-12-15 23:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfDay()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -442,33 +457,34 @@ func TestCarbon_StartOfHour(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-15 23:00:00"},
{"2020-05-15 23:59:59", "2020-05-15 23:00:00"},
{"2020-06-15 23:59:59", "2020-06-15 23:00:00"},
{"2020-07-15 23:59:59", "2020-07-15 23:00:00"},
{"2020-08-15 13:14:15", "2020-08-15 13:00:00"},
{"2020-09-15 13:14:15", "2020-09-15 13:00:00"},
{"2020-10-15", "2020-10-15 00:00:00"},
{"2020-11-15", "2020-11-15 00:00:00"},
{"2020-12-15", "2020-12-15 00:00:00"},
{6, "2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{7, "2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{8, "2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{9, "2020-04-15 23:59:59", "2020-04-15 23:00:00"},
{10, "2020-05-15 23:59:59", "2020-05-15 23:00:00"},
{11, "2020-06-15 23:59:59", "2020-06-15 23:00:00"},
{12, "2020-07-15 23:59:59", "2020-07-15 23:00:00"},
{13, "2020-08-15 13:14:15", "2020-08-15 13:00:00"},
{14, "2020-09-15 13:14:15", "2020-09-15 13:00:00"},
{15, "2020-10-15", "2020-10-15 00:00:00"},
{16, "2020-11-15", "2020-11-15 00:00:00"},
{17, "2020-12-15", "2020-12-15 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfHour()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -476,33 +492,34 @@ func TestCarbon_EndOfHour(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:59:59"},
{"2020-02-15 00:00:00", "2020-02-15 00:59:59"},
{"2020-03-15 00:00:00", "2020-03-15 00:59:59"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-15 13:59:59"},
{"2020-09-15 13:14:15", "2020-09-15 13:59:59"},
{"2020-10-15", "2020-10-15 00:59:59"},
{"2020-11-15", "2020-11-15 00:59:59"},
{"2020-12-15", "2020-12-15 00:59:59"},
{6, "2020-01-15 00:00:00", "2020-01-15 00:59:59"},
{7, "2020-02-15 00:00:00", "2020-02-15 00:59:59"},
{8, "2020-03-15 00:00:00", "2020-03-15 00:59:59"},
{9, "2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{10, "2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{11, "2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{12, "2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{13, "2020-08-15 13:14:15", "2020-08-15 13:59:59"},
{14, "2020-09-15 13:14:15", "2020-09-15 13:59:59"},
{15, "2020-10-15", "2020-10-15 00:59:59"},
{16, "2020-11-15", "2020-11-15 00:59:59"},
{17, "2020-12-15", "2020-12-15 00:59:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfHour()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -510,33 +527,34 @@ func TestCarbon_StartOfMinute(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:00"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:00"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:00"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:00"},
{"2020-08-15 13:14:15", "2020-08-15 13:14:00"},
{"2020-09-15 13:14:15", "2020-09-15 13:14:00"},
{"2020-10-15", "2020-10-15 00:00:00"},
{"2020-11-15", "2020-11-15 00:00:00"},
{"2020-12-15", "2020-12-15 00:00:00"},
{6, "2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{7, "2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{8, "2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{9, "2020-04-15 23:59:59", "2020-04-15 23:59:00"},
{10, "2020-05-15 23:59:59", "2020-05-15 23:59:00"},
{11, "2020-06-15 23:59:59", "2020-06-15 23:59:00"},
{12, "2020-07-15 23:59:59", "2020-07-15 23:59:00"},
{13, "2020-08-15 13:14:15", "2020-08-15 13:14:00"},
{14, "2020-09-15 13:14:15", "2020-09-15 13:14:00"},
{15, "2020-10-15", "2020-10-15 00:00:00"},
{16, "2020-11-15", "2020-11-15 00:00:00"},
{17, "2020-12-15", "2020-12-15 00:00:00"},
}
for _, test := range tests {
c := Parse(test.input).StartOfMinute()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -544,33 +562,34 @@ func TestCarbon_EndOfMinute(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:59"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:59"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:59"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-15 13:14:59"},
{"2020-09-15 13:14:15", "2020-09-15 13:14:59"},
{"2020-10-15", "2020-10-15 00:00:59"},
{"2020-11-15", "2020-11-15 00:00:59"},
{"2020-12-15", "2020-12-15 00:00:59"},
{6, "2020-01-15 00:00:00", "2020-01-15 00:00:59"},
{7, "2020-02-15 00:00:00", "2020-02-15 00:00:59"},
{8, "2020-03-15 00:00:00", "2020-03-15 00:00:59"},
{9, "2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{10, "2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{11, "2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{12, "2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{13, "2020-08-15 13:14:15", "2020-08-15 13:14:59"},
{14, "2020-09-15 13:14:15", "2020-09-15 13:14:59"},
{15, "2020-10-15", "2020-10-15 00:00:59"},
{16, "2020-11-15", "2020-11-15 00:00:59"},
{17, "2020-12-15", "2020-12-15 00:00:59"},
}
for _, test := range tests {
c := Parse(test.input).EndOfMinute()
assert.Nil(c.Error)
assert.Equal(c.ToDateTimeString(), test.output)
assert.Equal(c.ToDateTimeString(), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -578,33 +597,34 @@ func TestCarbon_StartOfSecond(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00.123", "2020-01-15 00:00:00.0"},
{"2020-02-15 00:00:00.123", "2020-02-15 00:00:00.0"},
{"2020-03-15 00:00:00.123", "2020-03-15 00:00:00.0"},
{"2020-04-15 23:59:59.123", "2020-04-15 23:59:59.0"},
{"2020-05-15 23:59:59.123", "2020-05-15 23:59:59.0"},
{"2020-06-15 23:59:59.123", "2020-06-15 23:59:59.0"},
{"2020-07-15 23:59:59.123", "2020-07-15 23:59:59.0"},
{"2020-08-15 13:14:15.123", "2020-08-15 13:14:15.0"},
{"2020-09-15 13:14:15.123", "2020-09-15 13:14:15.0"},
{"2020-10-15", "2020-10-15 00:00:00.0"},
{"2020-11-15", "2020-11-15 00:00:00.0"},
{"2020-12-15", "2020-12-15 00:00:00.0"},
{6, "2020-01-15 00:00:00.123", "2020-01-15 00:00:00.0"},
{7, "2020-02-15 00:00:00.123", "2020-02-15 00:00:00.0"},
{8, "2020-03-15 00:00:00.123", "2020-03-15 00:00:00.0"},
{9, "2020-04-15 23:59:59.123", "2020-04-15 23:59:59.0"},
{10, "2020-05-15 23:59:59.123", "2020-05-15 23:59:59.0"},
{11, "2020-06-15 23:59:59.123", "2020-06-15 23:59:59.0"},
{12, "2020-07-15 23:59:59.123", "2020-07-15 23:59:59.0"},
{13, "2020-08-15 13:14:15.123", "2020-08-15 13:14:15.0"},
{14, "2020-09-15 13:14:15.123", "2020-09-15 13:14:15.0"},
{15, "2020-10-15", "2020-10-15 00:00:00.0"},
{16, "2020-11-15", "2020-11-15 00:00:00.0"},
{17, "2020-12-15", "2020-12-15 00:00:00.0"},
}
for _, test := range tests {
c := Parse(test.input).StartOfSecond()
assert.Nil(c.Error)
assert.Equal(c.Format("Y-m-d H:i:s.u"), test.output)
assert.Equal(c.Format("Y-m-d H:i:s.u"), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}
@ -612,32 +632,33 @@ func TestCarbon_EndOfSecond(t *testing.T) {
assert := assert.New(t)
tests := []struct {
id int // 测试id
input string // 输入值
output string // 期望输出值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{1, "", ""},
{2, "0", ""},
{3, "0000-00-00", ""},
{4, "00:00:00", ""},
{5, "0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00.123", "2020-01-15 00:00:00.999"},
{"2020-02-15 00:00:00.123", "2020-02-15 00:00:00.999"},
{"2020-03-15 00:00:00.123", "2020-03-15 00:00:00.999"},
{"2020-04-15 23:59:59.123", "2020-04-15 23:59:59.999"},
{"2020-05-15 23:59:59.123", "2020-05-15 23:59:59.999"},
{"2020-06-15 23:59:59.123", "2020-06-15 23:59:59.999"},
{"2020-07-15 23:59:59.123", "2020-07-15 23:59:59.999"},
{"2020-08-15 13:14:15.123", "2020-08-15 13:14:15.999"},
{"2020-09-15 13:14:15.123", "2020-09-15 13:14:15.999"},
{"2020-10-15", "2020-10-15 00:00:00.999"},
{"2020-11-15", "2020-11-15 00:00:00.999"},
{"2020-12-15", "2020-12-15 00:00:00.999"},
{6, "2020-01-15 00:00:00.123", "2020-01-15 00:00:00.999"},
{7, "2020-02-15 00:00:00.123", "2020-02-15 00:00:00.999"},
{8, "2020-03-15 00:00:00.123", "2020-03-15 00:00:00.999"},
{9, "2020-04-15 23:59:59.123", "2020-04-15 23:59:59.999"},
{10, "2020-05-15 23:59:59.123", "2020-05-15 23:59:59.999"},
{11, "2020-06-15 23:59:59.123", "2020-06-15 23:59:59.999"},
{12, "2020-07-15 23:59:59.123", "2020-07-15 23:59:59.999"},
{13, "2020-08-15 13:14:15.123", "2020-08-15 13:14:15.999"},
{14, "2020-09-15 13:14:15.123", "2020-09-15 13:14:15.999"},
{15, "2020-10-15", "2020-10-15 00:00:00.999"},
{16, "2020-11-15", "2020-11-15 00:00:00.999"},
{17, "2020-12-15", "2020-12-15 00:00:00.999"},
}
for _, test := range tests {
c := Parse(test.input).EndOfSecond()
assert.Nil(c.Error)
assert.Equal(c.Format("Y-m-d H:i:s.u"), test.output)
assert.Equal(c.Format("Y-m-d H:i:s.u"), test.output, "Current test id is "+strconv.Itoa(test.id))
}
}