diff --git a/calendar.lunar_test.go b/calendar.lunar_test.go index 8a5d6612..df9f18b7 100755 --- a/calendar.lunar_test.go +++ b/calendar.lunar_test.go @@ -15,32 +15,32 @@ func TestLunar_Animal(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-05-01", "鼠"}, - {"2020-08-05", "鼠"}, - {"2021-07-07", "牛"}, - {"2010-08-05", "虎"}, - {"2011-08-05", "兔"}, - {"2012-08-05", "龙"}, - {"2013-08-05", "蛇"}, - {"2014-08-05", "马"}, - {"2015-08-05", "羊"}, - {"2016-08-05", "猴"}, - {"2017-08-05", "鸡"}, - {"2018-08-05", "狗"}, - {"2019-08-05", "猪"}, - {"2020-04-23", "鼠"}, - {"2020-05-23", "鼠"}, // 特殊边界值 - {"2020-06-21", "鼠"}, // 特殊边界值 - {"2020-08-05", "鼠"}, - {"2021-05-12", "牛"}, - {"2021-08-05", "牛"}, - {"2200-08-05", ""}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-05-01", "鼠"}, + 6: {"2020-08-05", "鼠"}, + 7: {"2021-07-07", "牛"}, + 8: {"2010-08-05", "虎"}, + 9: {"2011-08-05", "兔"}, + 10: {"2012-08-05", "龙"}, + 11: {"2013-08-05", "蛇"}, + 12: {"2014-08-05", "马"}, + 13: {"2015-08-05", "羊"}, + 14: {"2016-08-05", "猴"}, + 15: {"2017-08-05", "鸡"}, + 16: {"2018-08-05", "狗"}, + 17: {"2019-08-05", "猪"}, + 18: {"2020-04-23", "鼠"}, + 19: {"2020-05-23", "鼠"}, // special boundary + 20: {"2020-06-21", "鼠"}, // special boundary + 21: {"2020-08-05", "鼠"}, + 22: {"2021-05-12", "牛"}, + 23: {"2021-08-05", "牛"}, + 24: {"2200-08-05", ""}, } for index, test := range tests { @@ -57,26 +57,26 @@ func TestLunar_Festival(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-04-23", ""}, - {"2021-02-12", "春节"}, - {"2021-02-26", "元宵节"}, - {"2021-05-12", ""}, - {"2021-06-14", "端午节"}, - {"2021-08-14", "七夕节"}, - {"2021-08-22", "中元节"}, - {"2021-09-21", "中秋节"}, - {"2021-10-14", "重阳节"}, - {"2021-10-14", "重阳节"}, - {"2021-11-05", "寒衣节"}, - {"2021-11-19", "下元节"}, - {"2022-01-10", "腊八节"}, - {"2022-01-25", "小年"}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-04-23", ""}, + 6: {"2021-02-12", "春节"}, + 7: {"2021-02-26", "元宵节"}, + 8: {"2021-05-12", ""}, + 9: {"2021-06-14", "端午节"}, + 10: {"2021-08-14", "七夕节"}, + 11: {"2021-08-22", "中元节"}, + 12: {"2021-09-21", "中秋节"}, + 13: {"2021-10-14", "重阳节"}, + 14: {"2021-10-14", "重阳节"}, + 15: {"2021-11-05", "寒衣节"}, + 16: {"2021-11-19", "下元节"}, + 17: {"2022-01-10", "腊八节"}, + 18: {"2022-01-25", "小年"}, } for index, test := range tests { @@ -93,13 +93,13 @@ func TestLunar_DateTime(t *testing.T) { input string // 输入值 year, month, day, hour, minute, second int // 期望值 }{ - {"", 0, 0, 0, 0, 0, 0}, - {"0", 0, 0, 0, 0, 0, 0}, - {"0000-00-00", 0, 0, 0, 0, 0, 0}, - {"00:00:00", 0, 0, 0, 0, 0, 0}, - {"0000-00-00 00:00:00", 0, 0, 0, 0, 0, 0}, + 0: {"", 0, 0, 0, 0, 0, 0}, + 1: {"0", 0, 0, 0, 0, 0, 0}, + 2: {"0000-00-00", 0, 0, 0, 0, 0, 0}, + 3: {"00:00:00", 0, 0, 0, 0, 0, 0}, + 4: {"0000-00-00 00:00:00", 0, 0, 0, 0, 0, 0}, - {"2020-08-05 13:14:15", 2020, 6, 16, 13, 14, 15}, + 5: {"2020-08-05 13:14:15", 2020, 6, 16, 13, 14, 15}, } for index, test := range tests { @@ -122,13 +122,13 @@ func TestLunar_Date(t *testing.T) { input string // 输入值 year, month, day int // 期望值 }{ - {"", 0, 0, 0}, - {"0", 0, 0, 0}, - {"0000-00-00", 0, 0, 0}, - {"00:00:00", 0, 0, 0}, - {"0000-00-00 00:00:00", 0, 0, 0}, + 0: {"", 0, 0, 0}, + 1: {"0", 0, 0, 0}, + 2: {"0000-00-00", 0, 0, 0}, + 3: {"00:00:00", 0, 0, 0}, + 4: {"0000-00-00 00:00:00", 0, 0, 0}, - {"2020-08-05 13:14:15", 2020, 6, 16}, + 5: {"2020-08-05 13:14:15", 2020, 6, 16}, } for index, test := range tests { @@ -148,13 +148,13 @@ func TestLunar_Time(t *testing.T) { input string // 输入值 hour, minute, second int // 期望值 }{ - {"", 0, 0, 0}, - {"0", 0, 0, 0}, - {"0000-00-00", 0, 0, 0}, - {"00:00:00", 0, 0, 0}, - {"0000-00-00 00:00:00", 0, 0, 0}, + 0: {"", 0, 0, 0}, + 1: {"0", 0, 0, 0}, + 2: {"0000-00-00", 0, 0, 0}, + 3: {"00:00:00", 0, 0, 0}, + 4: {"0000-00-00 00:00:00", 0, 0, 0}, - {"2020-08-05 13:14:15", 13, 14, 15}, + 5: {"2020-08-05 13:14:15", 13, 14, 15}, } for index, test := range tests { @@ -174,18 +174,18 @@ func TestLunar_Year(t *testing.T) { input string // 输入值 expected int // 期望值 }{ - {"", 0}, - {"0", 0}, - {"0000-00-00", 0}, - {"00:00:00", 0}, - {"0000-00-00 00:00:00", 0}, + 0: {"", 0}, + 1: {"0", 0}, + 2: {"0000-00-00", 0}, + 3: {"00:00:00", 0}, + 4: {"0000-00-00 00:00:00", 0}, - {"2020-04-23", 2020}, - {"2020-05-01", 2020}, - {"2020-08-05", 2020}, - {"2021-01-01", 2020}, - {"2021-05-12", 2021}, - {"2021-07-07", 2021}, + 5: {"2020-04-23", 2020}, + 6: {"2020-05-01", 2020}, + 7: {"2020-08-05", 2020}, + 8: {"2021-01-01", 2020}, + 9: {"2021-05-12", 2021}, + 10: {"2021-07-07", 2021}, } for index, test := range tests { @@ -202,24 +202,24 @@ func TestLunar_Month(t *testing.T) { input string // 输入值 expected int // 期望值 }{ - {"", 0}, - {"0", 0}, - {"0000-00-00", 0}, - {"00:00:00", 0}, - {"0000-00-00 00:00:00", 0}, - - {"2021-01-05", 11}, - {"2021-02-05", 12}, - {"2021-03-05", 1}, - {"2021-04-05", 2}, - {"2021-05-05", 3}, - {"2021-06-05", 4}, - {"2021-07-05", 5}, - {"2021-08-05", 6}, - {"2021-09-05", 7}, - {"2021-10-05", 8}, - {"2021-11-05", 10}, - {"2021-12-05", 11}, + 0: {"", 0}, + 1: {"0", 0}, + 2: {"0000-00-00", 0}, + 3: {"00:00:00", 0}, + 4: {"0000-00-00 00:00:00", 0}, + + 5: {"2021-01-05", 11}, + 6: {"2021-02-05", 12}, + 7: {"2021-03-05", 1}, + 8: {"2021-04-05", 2}, + 9: {"2021-05-05", 3}, + 10: {"2021-06-05", 4}, + 11: {"2021-07-05", 5}, + 12: {"2021-08-05", 6}, + 13: {"2021-09-05", 7}, + 14: {"2021-10-05", 8}, + 15: {"2021-11-05", 10}, + 16: {"2021-12-05", 11}, } for index, test := range tests { @@ -236,43 +236,43 @@ func TestLunar_Day(t *testing.T) { input string // 输入值 expected int // 期望值 }{ - {"", 0}, - {"0", 0}, - {"0000-00-00", 0}, - {"00:00:00", 0}, - {"0000-00-00 00:00:00", 0}, - - {"2020-08-01", 12}, - {"2020-08-02", 13}, - {"2020-08-03", 14}, - {"2020-08-04", 15}, - {"2020-08-05", 16}, - {"2020-08-06", 17}, - {"2020-08-07", 18}, - {"2020-08-08", 19}, - {"2020-08-09", 20}, - {"2020-08-10", 21}, - {"2020-08-11", 22}, - {"2020-08-12", 23}, - {"2020-08-13", 24}, - {"2020-08-14", 25}, - {"2020-08-15", 26}, - {"2020-08-16", 27}, - {"2020-08-17", 28}, - {"2020-08-18", 29}, - {"2020-08-19", 1}, - {"2020-08-20", 2}, - {"2020-08-21", 3}, - {"2020-08-22", 4}, - {"2020-08-23", 5}, - {"2020-08-24", 6}, - {"2020-08-25", 7}, - {"2020-08-26", 8}, - {"2020-08-27", 9}, - {"2020-08-28", 10}, - {"2020-08-29", 11}, - {"2020-08-30", 12}, - {"2020-08-31", 13}, + 0: {"", 0}, + 1: {"0", 0}, + 2: {"0000-00-00", 0}, + 3: {"00:00:00", 0}, + 4: {"0000-00-00 00:00:00", 0}, + + 5: {"2020-08-01", 12}, + 6: {"2020-08-02", 13}, + 7: {"2020-08-03", 14}, + 8: {"2020-08-04", 15}, + 9: {"2020-08-05", 16}, + 10: {"2020-08-06", 17}, + 11: {"2020-08-07", 18}, + 12: {"2020-08-08", 19}, + 13: {"2020-08-09", 20}, + 14: {"2020-08-10", 21}, + 15: {"2020-08-11", 22}, + 16: {"2020-08-12", 23}, + 17: {"2020-08-13", 24}, + 18: {"2020-08-14", 25}, + 19: {"2020-08-15", 26}, + 20: {"2020-08-16", 27}, + 21: {"2020-08-17", 28}, + 22: {"2020-08-18", 29}, + 23: {"2020-08-19", 1}, + 24: {"2020-08-20", 2}, + 25: {"2020-08-21", 3}, + 26: {"2020-08-22", 4}, + 27: {"2020-08-23", 5}, + 28: {"2020-08-24", 6}, + 29: {"2020-08-25", 7}, + 30: {"2020-08-26", 8}, + 31: {"2020-08-27", 9}, + 32: {"2020-08-28", 10}, + 33: {"2020-08-29", 11}, + 34: {"2020-08-30", 12}, + 35: {"2020-08-31", 13}, } for index, test := range tests { @@ -289,16 +289,16 @@ func TestLunar_LeapMonth(t *testing.T) { input string // 输入值 expected int // 期望值 }{ - {"", 0}, - {"0", 0}, - {"0000-00-00", 0}, - {"00:00:00", 0}, - {"0000-00-00 00:00:00", 0}, + 0: {"", 0}, + 1: {"0", 0}, + 2: {"0000-00-00", 0}, + 3: {"00:00:00", 0}, + 4: {"0000-00-00 00:00:00", 0}, - {"2020-04-23", 4}, - {"2020-05-01", 4}, - {"2020-08-05", 4}, - {"2021-07-07", 0}, + 5: {"2020-04-23", 4}, + 6: {"2020-05-01", 4}, + 7: {"2020-08-05", 4}, + 8: {"2021-07-07", 0}, } for index, test := range tests { @@ -315,18 +315,18 @@ func TestLunar_ToYearString(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, - {"2020-04-23", "二零二零"}, - {"2020-05-01", "二零二零"}, - {"2020-08-05", "二零二零"}, - {"2021-01-01", "二零二零"}, - {"2021-05-12", "二零二一"}, - {"2021-07-07", "二零二一"}, + 5: {"2020-04-23", "二零二零"}, + 6: {"2020-05-01", "二零二零"}, + 7: {"2020-08-05", "二零二零"}, + 8: {"2021-01-01", "二零二零"}, + 9: {"2021-05-12", "二零二一"}, + 10: {"2021-07-07", "二零二一"}, } for index, test := range tests { @@ -343,29 +343,29 @@ func TestLunar_ToMonthString(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-01-01", "腊月"}, - {"2020-02-01", "正月"}, - {"2020-03-01", "二月"}, - {"2020-04-01", "三月"}, - {"2020-04-23", "四月"}, - {"2020-05-01", "四月"}, - {"2020-06-01", "四月"}, - {"2020-07-01", "五月"}, - {"2020-07-07", "五月"}, - {"2020-08-01", "六月"}, - {"2020-09-01", "七月"}, - {"2020-10-01", "八月"}, - {"2020-11-01", "九月"}, - {"2020-12-01", "十月"}, - {"2021-01-01", "十一月"}, - {"2021-02-01", "腊月"}, - {"2021-05-12", "四月"}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-01-01", "腊月"}, + 6: {"2020-02-01", "正月"}, + 7: {"2020-03-01", "二月"}, + 8: {"2020-04-01", "三月"}, + 9: {"2020-04-23", "四月"}, + 10: {"2020-05-01", "四月"}, + 11: {"2020-06-01", "四月"}, + 12: {"2020-07-01", "五月"}, + 13: {"2020-07-07", "五月"}, + 14: {"2020-08-01", "六月"}, + 15: {"2020-09-01", "七月"}, + 16: {"2020-10-01", "八月"}, + 17: {"2020-11-01", "九月"}, + 18: {"2020-12-01", "十月"}, + 19: {"2021-01-01", "十一月"}, + 20: {"2021-02-01", "腊月"}, + 21: {"2021-05-12", "四月"}, } for index, test := range tests { @@ -382,28 +382,28 @@ func TestLunar_ToDayString(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-01-01", "初七"}, - {"2020-02-01", "初八"}, - {"2020-03-01", "初八"}, - {"2020-04-01", "初九"}, - {"2020-04-23", "初一"}, - {"2020-05-01", "初九"}, - {"2020-06-01", "初十"}, - {"2020-07-01", "十一"}, - {"2020-08-01", "十二"}, - {"2020-09-01", "十四"}, - {"2020-10-01", "十五"}, - {"2020-11-01", "十六"}, - {"2020-12-01", "十七"}, - {"2021-01-03", "二十"}, - {"2021-01-05", "廿二"}, - {"2021-04-11", "三十"}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-01-01", "初七"}, + 6: {"2020-02-01", "初八"}, + 7: {"2020-03-01", "初八"}, + 8: {"2020-04-01", "初九"}, + 9: {"2020-04-23", "初一"}, + 10: {"2020-05-01", "初九"}, + 11: {"2020-06-01", "初十"}, + 12: {"2020-07-01", "十一"}, + 13: {"2020-08-01", "十二"}, + 14: {"2020-09-01", "十四"}, + 15: {"2020-10-01", "十五"}, + 16: {"2020-11-01", "十六"}, + 17: {"2020-12-01", "十七"}, + 18: {"2021-01-03", "二十"}, + 19: {"2021-01-05", "廿二"}, + 20: {"2021-04-11", "三十"}, } for index, test := range tests { @@ -420,25 +420,25 @@ func TestLunar_String(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-01-01", "2019-12-07 00:00:00"}, - {"2020-02-01", "2020-01-08 00:00:00"}, - {"2020-03-01", "2020-02-08 00:00:00"}, - {"2020-04-01", "2020-03-09 00:00:00"}, - {"2020-04-23", "2020-04-01 00:00:00"}, - {"2020-05-01", "2020-04-09 00:00:00"}, - {"2020-06-01", "2020-04-10 00:00:00"}, - {"2020-07-01", "2020-05-11 00:00:00"}, - {"2020-08-01", "2020-06-12 00:00:00"}, - {"2020-09-01", "2020-07-14 00:00:00"}, - {"2020-10-01", "2020-08-15 00:00:00"}, - {"2020-11-01", "2020-09-16 00:00:00"}, - {"2020-12-01", "2020-10-17 00:00:00"}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-01-01", "2019-12-07 00:00:00"}, + 6: {"2020-02-01", "2020-01-08 00:00:00"}, + 7: {"2020-03-01", "2020-02-08 00:00:00"}, + 8: {"2020-04-01", "2020-03-09 00:00:00"}, + 9: {"2020-04-23", "2020-04-01 00:00:00"}, + 10: {"2020-05-01", "2020-04-09 00:00:00"}, + 11: {"2020-06-01", "2020-04-10 00:00:00"}, + 12: {"2020-07-01", "2020-05-11 00:00:00"}, + 13: {"2020-08-01", "2020-06-12 00:00:00"}, + 14: {"2020-09-01", "2020-07-14 00:00:00"}, + 15: {"2020-10-01", "2020-08-15 00:00:00"}, + 16: {"2020-11-01", "2020-09-16 00:00:00"}, + 17: {"2020-12-01", "2020-10-17 00:00:00"}, } for index, test := range tests { @@ -455,25 +455,25 @@ func TestLunar_ToDateString(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-01-01", "二零一九年腊月初七"}, - {"2020-02-01", "二零二零年正月初八"}, - {"2020-03-01", "二零二零年二月初八"}, - {"2020-04-01", "二零二零年三月初九"}, - {"2020-04-23", "二零二零年四月初一"}, - {"2020-05-01", "二零二零年四月初九"}, - {"2020-06-01", "二零二零年四月初十"}, - {"2020-07-01", "二零二零年五月十一"}, - {"2020-08-01", "二零二零年六月十二"}, - {"2020-09-01", "二零二零年七月十四"}, - {"2020-10-01", "二零二零年八月十五"}, - {"2020-11-01", "二零二零年九月十六"}, - {"2020-12-01", "二零二零年十月十七"}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-01-01", "二零一九年腊月初七"}, + 6: {"2020-02-01", "二零二零年正月初八"}, + 7: {"2020-03-01", "二零二零年二月初八"}, + 8: {"2020-04-01", "二零二零年三月初九"}, + 9: {"2020-04-23", "二零二零年四月初一"}, + 10: {"2020-05-01", "二零二零年四月初九"}, + 11: {"2020-06-01", "二零二零年四月初十"}, + 12: {"2020-07-01", "二零二零年五月十一"}, + 13: {"2020-08-01", "二零二零年六月十二"}, + 14: {"2020-09-01", "二零二零年七月十四"}, + 15: {"2020-10-01", "二零二零年八月十五"}, + 16: {"2020-11-01", "二零二零年九月十六"}, + 17: {"2020-12-01", "二零二零年十月十七"}, } for index, test := range tests { @@ -490,17 +490,17 @@ func TestLunar_IsLeapYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-04-23", true}, - {"2020-05-01", true}, - {"2020-08-05", true}, - {"2021-01-01", true}, - {"2021-07-07", false}, + 5: {"2020-04-23", true}, + 6: {"2020-05-01", true}, + 7: {"2020-08-05", true}, + 8: {"2021-01-01", true}, + 9: {"2021-07-07", false}, } for index, test := range tests { @@ -517,17 +517,17 @@ func TestLunar_IsLeapMonth(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-04-23", true}, - {"2020-05-01", true}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, + 5: {"2020-04-23", true}, + 6: {"2020-05-01", true}, + 7: {"2020-08-05", false}, + 8: {"2021-01-01", false}, + 9: {"2021-07-07", false}, } for index, test := range tests { @@ -544,16 +544,16 @@ func TestLunar_IsRatYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", true}, - {"2020-08-05", true}, - {"2021-01-01", true}, - {"2021-07-07", false}, + 5: {"2020-05-01", true}, + 6: {"2020-08-05", true}, + 7: {"2021-01-01", true}, + 8: {"2021-07-07", false}, } for index, test := range tests { @@ -570,16 +570,16 @@ func TestLunar_IsOxYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", true}, } for index, test := range tests { @@ -596,17 +596,17 @@ func TestLunar_IsTigerYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2022-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2022-08-05", true}, } for index, test := range tests { @@ -623,17 +623,17 @@ func TestLunar_IsRabbitYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2023-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2023-08-05", true}, } for index, test := range tests { @@ -650,17 +650,17 @@ func TestLunar_IsDragonYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2024-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2024-08-05", true}, } for index, test := range tests { @@ -677,17 +677,17 @@ func TestLunar_IsSnakeYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2025-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2025-08-05", true}, } for index, test := range tests { @@ -704,17 +704,17 @@ func TestLunar_IsHorseYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2026-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2026-08-05", true}, } for index, test := range tests { @@ -731,17 +731,17 @@ func TestLunar_IsGoatYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2027-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2027-08-05", true}, } for index, test := range tests { @@ -758,17 +758,17 @@ func TestLunar_IsMonkeyYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2028-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2028-08-05", true}, } for index, test := range tests { @@ -785,17 +785,17 @@ func TestLunar_IsRoosterYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2029-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2029-08-05", true}, } for index, test := range tests { @@ -812,17 +812,17 @@ func TestLunar_IsDogYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2030-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2030-08-05", true}, } for index, test := range tests { @@ -839,17 +839,17 @@ func TestLunar_IsPigYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-05-01", false}, - {"2020-08-05", false}, - {"2021-01-01", false}, - {"2021-07-07", false}, - {"2031-08-05", true}, + 5: {"2020-05-01", false}, + 6: {"2020-08-05", false}, + 7: {"2021-01-01", false}, + 8: {"2021-07-07", false}, + 9: {"2031-08-05", true}, } for index, test := range tests { @@ -866,26 +866,26 @@ func TestLunar_DoubleHour(t *testing.T) { input string // 输入值1 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - - {"2020-01-05 23:23:45", "子时"}, - {"2020-01-05 00:59:45", "子时"}, - {"2020-02-05 01:00:00", "丑时"}, - {"2020-02-05 03:40:00", "寅时"}, - {"2020-02-05 05:00:00", "卯时"}, - {"2020-02-05 07:30:00", "辰时"}, - {"2020-02-05 09:00:00", "巳时"}, - {"2020-02-05 11:00:00", "午时"}, - {"2020-02-05 13:00:00", "未时"}, - {"2020-02-05 15:00:00", "申时"}, - {"2020-02-05 14:59:00", "未时"}, - {"2020-02-05 17:00:00", "酉时"}, - {"2020-02-05 19:00:00", "戌时"}, - {"2020-02-05 21:00:00", "亥时"}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, + 4: {"0000-00-00 00:00:00", ""}, + + 5: {"2020-01-05 23:23:45", "子时"}, + 6: {"2020-01-05 00:59:45", "子时"}, + 7: {"2020-02-05 01:00:00", "丑时"}, + 8: {"2020-02-05 03:40:00", "寅时"}, + 9: {"2020-02-05 05:00:00", "卯时"}, + 10: {"2020-02-05 07:30:00", "辰时"}, + 11: {"2020-02-05 09:00:00", "巳时"}, + 12: {"2020-02-05 11:00:00", "午时"}, + 13: {"2020-02-05 13:00:00", "未时"}, + 14: {"2020-02-05 15:00:00", "申时"}, + 15: {"2020-02-05 14:59:00", "未时"}, + 16: {"2020-02-05 17:00:00", "酉时"}, + 17: {"2020-02-05 19:00:00", "戌时"}, + 18: {"2020-02-05 21:00:00", "亥时"}, } for index, test := range tests { @@ -902,16 +902,16 @@ func TestLunar_IsFirstDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 00:00:00", true}, - {"2020-04-19 00:59:59", true}, - {"2020-08-05 23:00:00", true}, - {"2020-08-05 01:00:00", false}, + 5: {"2020-03-21 00:00:00", true}, + 6: {"2020-04-19 00:59:59", true}, + 7: {"2020-08-05 23:00:00", true}, + 8: {"2020-08-05 01:00:00", false}, } for index, test := range tests { @@ -928,15 +928,15 @@ func TestLunar_IsSecondDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 01:00:00", true}, - {"2020-04-19 02:59:59", true}, - {"2020-08-05 03:00:00", false}, + 5: {"2020-03-21 01:00:00", true}, + 6: {"2020-04-19 02:59:59", true}, + 7: {"2020-08-05 03:00:00", false}, } for index, test := range tests { @@ -953,15 +953,15 @@ func TestLunar_IsThirdDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 03:00:00", true}, - {"2020-04-19 04:59:59", true}, - {"2020-08-05 05:00:00", false}, + 5: {"2020-03-21 03:00:00", true}, + 6: {"2020-04-19 04:59:59", true}, + 7: {"2020-08-05 05:00:00", false}, } for index, test := range tests { @@ -977,15 +977,15 @@ func TestLunar_IsFourthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 05:00:00", true}, - {"2020-04-19 06:59:59", true}, - {"2020-08-05 07:00:00", false}, + 5: {"2020-03-21 05:00:00", true}, + 6: {"2020-04-19 06:59:59", true}, + 7: {"2020-08-05 07:00:00", false}, } for index, test := range tests { @@ -1002,15 +1002,15 @@ func TestLunar_IsFifthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 07:00:00", true}, - {"2020-04-19 08:59:59", true}, - {"2020-08-05 09:00:00", false}, + 5: {"2020-03-21 07:00:00", true}, + 6: {"2020-04-19 08:59:59", true}, + 7: {"2020-08-05 09:00:00", false}, } for index, test := range tests { @@ -1027,15 +1027,15 @@ func TestLunar_IsSixthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 09:00:00", true}, - {"2020-04-19 10:59:59", true}, - {"2020-08-05 11:00:00", false}, + 5: {"2020-03-21 09:00:00", true}, + 6: {"2020-04-19 10:59:59", true}, + 7: {"2020-08-05 11:00:00", false}, } for index, test := range tests { @@ -1052,15 +1052,15 @@ func TestLunar_IsSeventhDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 11:00:00", true}, - {"2020-04-19 12:59:59", true}, - {"2020-08-05 13:00:00", false}, + 5: {"2020-03-21 11:00:00", true}, + 6: {"2020-04-19 12:59:59", true}, + 7: {"2020-08-05 13:00:00", false}, } for index, test := range tests { @@ -1077,15 +1077,15 @@ func TestLunar_IsEighthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 13:00:00", true}, - {"2020-04-19 14:59:59", true}, - {"2020-08-05 15:00:00", false}, + 5: {"2020-03-21 13:00:00", true}, + 6: {"2020-04-19 14:59:59", true}, + 7: {"2020-08-05 15:00:00", false}, } for index, test := range tests { @@ -1102,15 +1102,15 @@ func TestLunar_IsNinthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 15:00:00", true}, - {"2020-04-19 16:59:59", true}, - {"2020-08-05 17:00:00", false}, + 5: {"2020-03-21 15:00:00", true}, + 6: {"2020-04-19 16:59:59", true}, + 7: {"2020-08-05 17:00:00", false}, } for index, test := range tests { @@ -1127,15 +1127,15 @@ func TestLunar_IsTenthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 17:00:00", true}, - {"2020-04-19 18:59:59", true}, - {"2020-08-05 19:00:00", false}, + 5: {"2020-03-21 17:00:00", true}, + 6: {"2020-04-19 18:59:59", true}, + 7: {"2020-08-05 19:00:00", false}, } for index, test := range tests { @@ -1152,15 +1152,15 @@ func TestLunar_IsEleventhDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 19:00:00", true}, - {"2020-04-19 20:59:59", true}, - {"2020-08-05 21:00:00", false}, + 5: {"2020-03-21 19:00:00", true}, + 6: {"2020-04-19 20:59:59", true}, + 7: {"2020-08-05 21:00:00", false}, } for index, test := range tests { @@ -1177,15 +1177,15 @@ func TestLunar_IsTwelfthDoubleHour(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-03-21 21:00:00", true}, - {"2020-04-19 22:59:59", true}, - {"2020-08-05 23:00:00", false}, + 5: {"2020-03-21 21:00:00", true}, + 6: {"2020-04-19 22:59:59", true}, + 7: {"2020-08-05 23:00:00", false}, } for index, test := range tests { @@ -1196,7 +1196,6 @@ func TestLunar_IsTwelfthDoubleHour(t *testing.T) { } func TestError_Lunar(t *testing.T) { - year, month, day, timezone := 1840, 1, 1, "xxx" - c := CreateFromDate(year, month, day, timezone).Lunar() + c := CreateFromDate(1840, 1, 1, "xxx").Lunar() assert.NotNil(t, c.Error, "It should catch an exception in Lunar()") } diff --git a/comparer_test.go b/comparer_test.go index c7325eb9..3a99a289 100755 --- a/comparer_test.go +++ b/comparer_test.go @@ -14,13 +14,13 @@ func TestCarbon_IsZero(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", true}, - {"0", true}, - {"0000-00-00", true}, - {"00:00:00", true}, - {"0000-00-00 00:00:00", true}, + 0: {"", true}, + 1: {"0", true}, + 2: {"0000-00-00", true}, + 3: {"00:00:00", true}, + 4: {"0000-00-00 00:00:00", true}, - {"2020-08-05", false}, + 5: {"2020-08-05", false}, } for index, test := range tests { @@ -37,13 +37,13 @@ func TestCarbon_IsValid(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-08-05", true}, + 5: {"2020-08-05", true}, } for index, test := range tests { @@ -60,13 +60,13 @@ func TestCarbon_IsInvalid(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", true}, - {"0", true}, - {"0000-00-00", true}, - {"00:00:00", true}, - {"0000-00-00 00:00:00", true}, + 0: {"", true}, + 1: {"0", true}, + 2: {"0000-00-00", true}, + 3: {"00:00:00", true}, + 4: {"0000-00-00 00:00:00", true}, - {"2020-08-05", false}, + 5: {"2020-08-05", false}, } for index, test := range tests { @@ -83,15 +83,15 @@ func TestCarbon_IsNow(t *testing.T) { input Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), false}, - {Parse("0"), false}, - {Parse("0000-00-00"), false}, - {Parse("00:00:00"), false}, - {Parse("0000-00-00 00:00:00"), false}, + 0: {Parse(""), false}, + 1: {Parse("0"), false}, + 2: {Parse("0000-00-00"), false}, + 3: {Parse("00:00:00"), false}, + 4: {Parse("0000-00-00 00:00:00"), false}, - {Tomorrow(), false}, - {Now(), true}, - {Yesterday(), false}, + 5: {Tomorrow(), false}, + 6: {Now(), true}, + 7: {Yesterday(), false}, } for index, test := range tests { @@ -108,15 +108,15 @@ func TestCarbon_IsFuture(t *testing.T) { input Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), false}, - {Parse("0"), false}, - {Parse("0000-00-00"), false}, - {Parse("00:00:00"), false}, - {Parse("0000-00-00 00:00:00"), false}, + 0: {Parse(""), false}, + 1: {Parse("0"), false}, + 2: {Parse("0000-00-00"), false}, + 3: {Parse("00:00:00"), false}, + 4: {Parse("0000-00-00 00:00:00"), false}, - {Tomorrow(), true}, - {Now(), false}, - {Yesterday(), false}, + 5: {Tomorrow(), true}, + 6: {Now(), false}, + 7: {Yesterday(), false}, } for index, test := range tests { @@ -133,15 +133,15 @@ func TestCarbon_IsPast(t *testing.T) { input Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), false}, - {Parse("0"), false}, - {Parse("0000-00-00"), false}, - {Parse("00:00:00"), false}, - {Parse("0000-00-00 00:00:00"), false}, + 0: {Parse(""), false}, + 1: {Parse("0"), false}, + 2: {Parse("0000-00-00"), false}, + 3: {Parse("00:00:00"), false}, + 4: {Parse("0000-00-00 00:00:00"), false}, - {Tomorrow(), false}, - {Now(), false}, - {Yesterday(), true}, + 5: {Tomorrow(), false}, + 6: {Now(), false}, + 7: {Yesterday(), true}, } for index, test := range tests { @@ -158,19 +158,19 @@ func TestCarbon_IsLeapYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2015-01-01", false}, - {"2016-01-01", true}, - {"2017-01-01", false}, - {"2018-01-01", false}, - {"2019-01-01", false}, - {"2020-01-01", true}, - {"2021-01-01", false}, + 5: {"2015-01-01", false}, + 6: {"2016-01-01", true}, + 7: {"2017-01-01", false}, + 8: {"2018-01-01", false}, + 9: {"2019-01-01", false}, + 10: {"2020-01-01", true}, + 11: {"2021-01-01", false}, } for index, test := range tests { @@ -187,19 +187,19 @@ func TestCarbon_IsLongYear(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2015-01-01", true}, - {"2016-01-01", false}, - {"2017-01-01", false}, - {"2018-01-01", false}, - {"2019-01-01", false}, - {"2020-01-01", true}, - {"2021-01-01", false}, + 5: {"2015-01-01", true}, + 6: {"2016-01-01", false}, + 7: {"2017-01-01", false}, + 8: {"2018-01-01", false}, + 9: {"2019-01-01", false}, + 10: {"2020-01-01", true}, + 11: {"2021-01-01", false}, } for index, test := range tests { @@ -216,24 +216,24 @@ func TestCarbon_IsJanuary(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", true}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", true}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -250,24 +250,24 @@ func TestCarbon_IsFebruary(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", true}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", true}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -284,24 +284,24 @@ func TestCarbon_IsMarch(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", true}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", true}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -318,24 +318,24 @@ func TestCarbon_IsApril(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", true}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", true}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -352,24 +352,24 @@ func TestCarbon_IsMay(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", true}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", true}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -386,24 +386,24 @@ func TestCarbon_IsJune(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", true}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", true}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -420,24 +420,24 @@ func TestCarbon_IsJuly(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", true}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", true}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -454,24 +454,24 @@ func TestCarbon_IsAugust(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", true}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", true}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -488,24 +488,24 @@ func TestCarbon_IsSeptember(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", true}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", true}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -522,24 +522,24 @@ func TestCarbon_IsOctober(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", true}, - {"2020-11-01", false}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", true}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -556,24 +556,24 @@ func TestCarbon_IsNovember(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", true}, - {"2020-12-01", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", true}, + 16: {"2020-12-01", false}, } for index, test := range tests { @@ -590,24 +590,24 @@ func TestCarbon_IsDecember(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, - - {"2020-01-01", false}, - {"2020-02-01", false}, - {"2020-03-01", false}, - {"2020-04-01", false}, - {"2020-05-01", false}, - {"2020-06-01", false}, - {"2020-07-01", false}, - {"2020-08-01", false}, - {"2020-09-01", false}, - {"2020-10-01", false}, - {"2020-11-01", false}, - {"2020-12-01", true}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, + + 5: {"2020-01-01", false}, + 6: {"2020-02-01", false}, + 7: {"2020-03-01", false}, + 8: {"2020-04-01", false}, + 9: {"2020-05-01", false}, + 10: {"2020-06-01", false}, + 11: {"2020-07-01", false}, + 12: {"2020-08-01", false}, + 13: {"2020-09-01", false}, + 14: {"2020-10-01", false}, + 15: {"2020-11-01", false}, + 16: {"2020-12-01", true}, } for index, test := range tests { @@ -624,19 +624,19 @@ func TestCarbon_IsMonday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", true}, - {"2020-10-06", false}, - {"2020-10-07", false}, - {"2020-10-08", false}, - {"2020-10-09", false}, - {"2020-10-10", false}, - {"2020-10-11", false}, + 5: {"2020-10-05", true}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -653,19 +653,19 @@ func TestCarbon_IsTuesday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", true}, - {"2020-10-07", false}, - {"2020-10-08", false}, - {"2020-10-09", false}, - {"2020-10-10", false}, - {"2020-10-11", false}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", true}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -682,19 +682,19 @@ func TestCarbon_IsWednesday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", false}, - {"2020-10-07", true}, - {"2020-10-08", false}, - {"2020-10-09", false}, - {"2020-10-10", false}, - {"2020-10-11", false}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", true}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -711,19 +711,19 @@ func TestCarbon_IsThursday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", false}, - {"2020-10-07", false}, - {"2020-10-08", true}, - {"2020-10-09", false}, - {"2020-10-10", false}, - {"2020-10-11", false}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", true}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -740,19 +740,19 @@ func TestCarbon_IsFriday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", false}, - {"2020-10-07", false}, - {"2020-10-08", false}, - {"2020-10-09", true}, - {"2020-10-10", false}, - {"2020-10-11", false}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", true}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -769,19 +769,19 @@ func TestCarbon_IsSaturday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", false}, - {"2020-10-07", false}, - {"2020-10-08", false}, - {"2020-10-09", false}, - {"2020-10-10", true}, - {"2020-10-11", false}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", true}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -798,19 +798,19 @@ func TestCarbon_IsSunday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", false}, - {"2020-10-07", false}, - {"2020-10-08", false}, - {"2020-10-09", false}, - {"2020-10-10", false}, - {"2020-10-11", true}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", true}, } for index, test := range tests { @@ -827,19 +827,19 @@ func TestCarbon_IsWeekday(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", true}, - {"2020-10-06", true}, - {"2020-10-07", true}, - {"2020-10-08", true}, - {"2020-10-09", true}, - {"2020-10-10", false}, - {"2020-10-11", false}, + 5: {"2020-10-05", true}, + 6: {"2020-10-06", true}, + 7: {"2020-10-07", true}, + 8: {"2020-10-08", true}, + 9: {"2020-10-09", true}, + 10: {"2020-10-10", false}, + 11: {"2020-10-11", false}, } for index, test := range tests { @@ -856,19 +856,19 @@ func TestCarbon_IsWeekend(t *testing.T) { input string // 输入值 expected bool // 期望值 }{ - {"", false}, - {"0", false}, - {"0000-00-00", false}, - {"00:00:00", false}, - {"0000-00-00 00:00:00", false}, + 0: {"", false}, + 1: {"0", false}, + 2: {"0000-00-00", false}, + 3: {"00:00:00", false}, + 4: {"0000-00-00 00:00:00", false}, - {"2020-10-05", false}, - {"2020-10-06", false}, - {"2020-10-07", false}, - {"2020-10-08", false}, - {"2020-10-09", false}, - {"2020-10-10", true}, - {"2020-10-11", true}, + 5: {"2020-10-05", false}, + 6: {"2020-10-06", false}, + 7: {"2020-10-07", false}, + 8: {"2020-10-08", false}, + 9: {"2020-10-09", false}, + 10: {"2020-10-10", true}, + 11: {"2020-10-11", true}, } for index, test := range tests { @@ -885,10 +885,10 @@ func TestCarbon_IsYesterday(t *testing.T) { input Carbon // 输入值 expected bool // 期望值 }{ - {NewCarbon(), false}, - {Now(), false}, - {Yesterday(), true}, - {Tomorrow(), false}, + 0: {NewCarbon(), false}, + 1: {Now(), false}, + 2: {Yesterday(), true}, + 3: {Tomorrow(), false}, } for index, test := range tests { @@ -905,10 +905,10 @@ func TestCarbon_IsToday(t *testing.T) { input Carbon // 输入值 expected bool // 期望值 }{ - {NewCarbon(), false}, - {Now(), true}, - {Yesterday(), false}, - {Tomorrow(), false}, + 0: {NewCarbon(), false}, + 1: {Now(), true}, + 2: {Yesterday(), false}, + 3: {Tomorrow(), false}, } for index, test := range tests { @@ -925,10 +925,10 @@ func TestCarbon_IsTomorrow(t *testing.T) { input Carbon // 输入值 expected bool // 期望值 }{ - {NewCarbon(), false}, - {Now(), false}, - {Yesterday(), false}, - {Tomorrow(), true}, + 0: {NewCarbon(), false}, + 1: {Now(), false}, + 2: {Yesterday(), false}, + 3: {Tomorrow(), true}, } for index, test := range tests { @@ -946,9 +946,9 @@ func TestCarbon_IsSameCentury(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05"), Parse("3020-08-05"), false}, - {Parse("2020-08-05"), Parse("2099-08-05"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05"), Parse("3020-08-05"), false}, + 2: {Parse("2020-08-05"), Parse("2099-08-05"), true}, } for index, test := range tests { @@ -966,10 +966,10 @@ func TestCarbon_IsSameDecade(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05"), Parse("2030-08-05"), false}, - {Parse("2020-08-05"), Parse("2021-08-05"), true}, - {Parse("2020-01-01"), Parse("2120-01-31"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05"), Parse("2030-08-05"), false}, + 2: {Parse("2020-08-05"), Parse("2021-08-05"), true}, + 3: {Parse("2020-01-01"), Parse("2120-01-31"), true}, } for index, test := range tests { @@ -987,9 +987,9 @@ func TestCarbon_IsSameYear(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05"), Parse("2021-08-05"), false}, - {Parse("2020-01-01"), Parse("2020-12-31"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05"), Parse("2021-08-05"), false}, + 2: {Parse("2020-01-01"), Parse("2020-12-31"), true}, } for index, test := range tests { @@ -1007,9 +1007,9 @@ func TestCarbon_IsSameQuarter(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05"), Parse("2020-01-05"), false}, - {Parse("2020-01-01"), Parse("2020-01-31"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05"), Parse("2020-01-05"), false}, + 2: {Parse("2020-01-01"), Parse("2020-01-31"), true}, } for index, test := range tests { @@ -1027,9 +1027,9 @@ func TestCarbon_IsSameMonth(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05"), Parse("2021-08-05"), false}, - {Parse("2020-01-01"), Parse("2020-01-31"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05"), Parse("2021-08-05"), false}, + 2: {Parse("2020-01-01"), Parse("2020-01-31"), true}, } for index, test := range tests { @@ -1047,9 +1047,9 @@ func TestCarbon_IsSameDay(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, - {Parse("2020-08-05 00:00:00"), Parse("2020-08-05 13:14:15"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, + 2: {Parse("2020-08-05 00:00:00"), Parse("2020-08-05 13:14:15"), true}, } for index, test := range tests { @@ -1067,9 +1067,9 @@ func TestCarbon_IsSameHour(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, - {Parse("2020-08-05 13:00:00"), Parse("2020-08-05 13:14:15"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, + 2: {Parse("2020-08-05 13:00:00"), Parse("2020-08-05 13:14:15"), true}, } for index, test := range tests { @@ -1087,9 +1087,9 @@ func TestCarbon_IsSameMinute(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, - {Parse("2020-08-05 13:14:00"), Parse("2020-08-05 13:14:15"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, + 2: {Parse("2020-08-05 13:14:00"), Parse("2020-08-05 13:14:15"), true}, } for index, test := range tests { @@ -1107,9 +1107,9 @@ func TestCarbon_IsSameSecond(t *testing.T) { input2 Carbon // 输入值 expected bool // 期望值 }{ - {Parse(""), Parse(""), false}, - {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, - {Parse("2020-08-05 13:14:15"), Parse("2020-08-05 13:14:15"), true}, + 0: {Parse(""), Parse(""), false}, + 1: {Parse("2020-08-05 13:14:15"), Parse("2021-08-05 13:14:15"), false}, + 2: {Parse("2020-08-05 13:14:15"), Parse("2020-08-05 13:14:15"), true}, } for index, test := range tests { @@ -1128,18 +1128,18 @@ func TestCarbon_Compare(t *testing.T) { param2 string // 输入参数2 expected bool // 期望值 }{ - {"2020-08-05", ">", "2020-08-04", true}, - {"2020-08-05", "<", "2020-08-04", false}, - {"2020-08-05", "<", "2020-08-06", true}, - {"2020-08-05", ">", "2020-08-06", false}, - {"2020-08-05", "=", "2020-08-05", true}, - {"2020-08-05", ">=", "2020-08-05", true}, - {"2020-08-05", "<=", "2020-08-05", true}, - {"2020-08-05", "!=", "2020-08-05", false}, - {"2020-08-05", "<>", "2020-08-05", false}, - {"2020-08-05", "!=", "2020-08-04", true}, - {"2020-08-05", "<>", "2020-08-04", true}, - {"2020-08-05", "+", "2020-08-04", false}, + 0: {"2020-08-05", ">", "2020-08-04", true}, + 1: {"2020-08-05", "<", "2020-08-04", false}, + 2: {"2020-08-05", "<", "2020-08-06", true}, + 3: {"2020-08-05", ">", "2020-08-06", false}, + 4: {"2020-08-05", "=", "2020-08-05", true}, + 5: {"2020-08-05", ">=", "2020-08-05", true}, + 6: {"2020-08-05", "<=", "2020-08-05", true}, + 7: {"2020-08-05", "!=", "2020-08-05", false}, + 8: {"2020-08-05", "<>", "2020-08-05", false}, + 9: {"2020-08-05", "!=", "2020-08-04", true}, + 10: {"2020-08-05", "<>", "2020-08-04", true}, + 11: {"2020-08-05", "+", "2020-08-04", false}, } for index, test := range tests { @@ -1158,9 +1158,9 @@ func TestCarbon_Gt(t *testing.T) { param string // 参数值 expected bool // 期望值 }{ - {"2020-08-05", "2020-08-05", false}, - {"2020-08-05", "2020-08-04", true}, - {"2020-08-05", "2020-08-06", false}, + 0: {"2020-08-05", "2020-08-05", false}, + 1: {"2020-08-05", "2020-08-04", true}, + 2: {"2020-08-05", "2020-08-06", false}, } for index, test := range tests { @@ -1179,9 +1179,9 @@ func TestCarbon_Lt(t *testing.T) { param string // 参数值 expected bool // 期望值 }{ - {"2020-08-05", "2020-08-05", false}, - {"2020-08-05", "2020-08-04", false}, - {"2020-08-05", "2020-08-06", true}, + 0: {"2020-08-05", "2020-08-05", false}, + 1: {"2020-08-05", "2020-08-04", false}, + 2: {"2020-08-05", "2020-08-06", true}, } for index, test := range tests { @@ -1200,9 +1200,9 @@ func TestCarbon_Eq(t *testing.T) { param string // 参数值 expected bool // 期望值 }{ - {"2020-08-05", "2020-08-05", true}, - {"2020-08-05", "2020-08-04", false}, - {"2020-08-05", "2020-08-06", false}, + 0: {"2020-08-05", "2020-08-05", true}, + 1: {"2020-08-05", "2020-08-04", false}, + 2: {"2020-08-05", "2020-08-06", false}, } for index, test := range tests { @@ -1221,9 +1221,9 @@ func TestCarbon_Ne(t *testing.T) { param string // 参数值 expected bool // 期望值 }{ - {"2020-08-05", "2020-08-05", false}, - {"2020-08-05", "2020-08-04", true}, - {"2020-08-05", "2020-08-06", true}, + 0: {"2020-08-05", "2020-08-05", false}, + 1: {"2020-08-05", "2020-08-04", true}, + 2: {"2020-08-05", "2020-08-06", true}, } for index, test := range tests { @@ -1242,9 +1242,9 @@ func TestCarbon_Gte(t *testing.T) { param string // 参数值 expected bool // 期望值 }{ - {"2020-08-05", "2020-08-05", true}, - {"2020-08-05", "2020-08-04", true}, - {"2020-08-05", "2020-08-06", false}, + 0: {"2020-08-05", "2020-08-05", true}, + 1: {"2020-08-05", "2020-08-04", true}, + 2: {"2020-08-05", "2020-08-06", false}, } for index, test := range tests { @@ -1263,9 +1263,9 @@ func TestCarbon_Lte(t *testing.T) { param string // 参数值 expected bool // 期望值 }{ - {"2020-08-05", "2020-08-05", true}, - {"2020-08-05", "2020-08-04", false}, - {"2020-08-05", "2020-08-06", true}, + 0: {"2020-08-05", "2020-08-05", true}, + 1: {"2020-08-05", "2020-08-04", false}, + 2: {"2020-08-05", "2020-08-06", true}, } for index, test := range tests { @@ -1333,10 +1333,10 @@ func TestCarbon_BetweenIncludedEnd(t *testing.T) { param2 string // 输入参数2 expected bool // 期望值 }{ - {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-05 13:14:15", false}, - {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-06 13:14:15", false}, - {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-05 13:14:15", true}, - {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-06 13:14:15", true}, + 0: {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-05 13:14:15", false}, + 1: {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-06 13:14:15", false}, + 2: {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-05 13:14:15", true}, + 3: {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-06 13:14:15", true}, } for index, test := range tests { @@ -1357,11 +1357,11 @@ func TestCarbon_BetweenIncludedBoth(t *testing.T) { param2 string // 输入参数2 expected bool // 期望值 }{ - {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-05 13:14:15", true}, - {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-06 13:14:15", true}, - {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-05 13:14:15", true}, - {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-06 13:14:15", true}, - {"2020-08-05 13:14:15", "2020-08-06 13:14:15", "2020-08-06 13:14:15", false}, + 0: {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-05 13:14:15", true}, + 1: {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "2020-08-06 13:14:15", true}, + 2: {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-05 13:14:15", true}, + 3: {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "2020-08-06 13:14:15", true}, + 4: {"2020-08-05 13:14:15", "2020-08-06 13:14:15", "2020-08-06 13:14:15", false}, } for index, test := range tests { diff --git a/language_test.go b/language_test.go index 31792a7a..2e2b28e3 100755 --- a/language_test.go +++ b/language_test.go @@ -15,8 +15,8 @@ func TestLanguage_SetLocale(t *testing.T) { locale string // 输入值 expected string // 期望值 }{ - {Now(), "en", "1 day after"}, - {Tomorrow(), "zh-CN", "1 天后"}, + 0: {Now(), "en", "1 day after"}, + 1: {Tomorrow(), "zh-CN", "1 天后"}, } for index, test := range tests { @@ -52,36 +52,36 @@ func TestLanguage_SetResources1(t *testing.T) { input2 string // 输入值 expected string // 期望值 }{ - {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "just now"}, - {"2020-08-05 13:14:15", "2021-08-05 13:14:15", "1 yr before"}, - {"2020-08-05 13:14:15", "2019-08-05 13:14:15", "1 yr after"}, - {"2020-08-05 13:14:15", "2030-08-05 13:14:15", "10 yrs before"}, - {"2020-08-05 13:14:15", "2010-08-05 13:14:15", "10 yrs after"}, - - {"2020-08-05 13:14:15", "2020-09-05 13:14:15", "1 mo before"}, - {"2020-08-05 13:14:15", "2020-07-05 13:14:15", "1 mo after"}, - {"2020-08-05 13:14:15", "2021-06-05 13:14:15", "10 mos before"}, - {"2020-08-05 13:14:15", "2019-10-05 13:14:15", "10 mos after"}, - - {"2020-08-05 13:14:15", "2020-08-06 13:14:15", "1d before"}, - {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "1d after"}, - {"2020-08-05 13:14:15", "2020-08-15 13:14:15", "1w before"}, - {"2020-08-05 13:14:15", "2020-07-26 13:14:15", "1w after"}, - - {"2020-08-05 13:14:15", "2020-08-05 14:14:15", "1h before"}, - {"2020-08-05 13:14:15", "2020-08-05 12:14:15", "1h after"}, - {"2020-08-05 13:14:15", "2020-08-05 23:14:15", "10h before"}, - {"2020-08-05 13:14:15", "2020-08-05 03:14:15", "10h after"}, - - {"2020-08-05 13:14:15", "2020-08-05 13:15:15", "1m before"}, - {"2020-08-05 13:14:15", "2020-08-05 13:13:15", "1m after"}, - {"2020-08-05 13:14:15", "2020-08-05 13:24:15", "10m before"}, - {"2020-08-05 13:14:15", "2020-08-05 13:04:15", "10m after"}, - - {"2020-08-05 13:14:15", "2020-08-05 13:14:16", "1s before"}, - {"2020-08-05 13:14:15", "2020-08-05 13:14:14", "1s after"}, - {"2020-08-05 13:14:15", "2020-08-05 13:14:25", "10s before"}, - {"2020-08-05 13:14:15", "2020-08-05 13:14:05", "10s after"}, + 0: {"2020-08-05 13:14:15", "2020-08-05 13:14:15", "just now"}, + 1: {"2020-08-05 13:14:15", "2021-08-05 13:14:15", "1 yr before"}, + 2: {"2020-08-05 13:14:15", "2019-08-05 13:14:15", "1 yr after"}, + 3: {"2020-08-05 13:14:15", "2030-08-05 13:14:15", "10 yrs before"}, + 4: {"2020-08-05 13:14:15", "2010-08-05 13:14:15", "10 yrs after"}, + + 5: {"2020-08-05 13:14:15", "2020-09-05 13:14:15", "1 mo before"}, + 6: {"2020-08-05 13:14:15", "2020-07-05 13:14:15", "1 mo after"}, + 7: {"2020-08-05 13:14:15", "2021-06-05 13:14:15", "10 mos before"}, + 8: {"2020-08-05 13:14:15", "2019-10-05 13:14:15", "10 mos after"}, + + 9: {"2020-08-05 13:14:15", "2020-08-06 13:14:15", "1d before"}, + 10: {"2020-08-05 13:14:15", "2020-08-04 13:14:15", "1d after"}, + 11: {"2020-08-05 13:14:15", "2020-08-15 13:14:15", "1w before"}, + 12: {"2020-08-05 13:14:15", "2020-07-26 13:14:15", "1w after"}, + + 13: {"2020-08-05 13:14:15", "2020-08-05 14:14:15", "1h before"}, + 14: {"2020-08-05 13:14:15", "2020-08-05 12:14:15", "1h after"}, + 15: {"2020-08-05 13:14:15", "2020-08-05 23:14:15", "10h before"}, + 16: {"2020-08-05 13:14:15", "2020-08-05 03:14:15", "10h after"}, + + 17: {"2020-08-05 13:14:15", "2020-08-05 13:15:15", "1m before"}, + 18: {"2020-08-05 13:14:15", "2020-08-05 13:13:15", "1m after"}, + 19: {"2020-08-05 13:14:15", "2020-08-05 13:24:15", "10m before"}, + 20: {"2020-08-05 13:14:15", "2020-08-05 13:04:15", "10m after"}, + + 21: {"2020-08-05 13:14:15", "2020-08-05 13:14:16", "1s before"}, + 22: {"2020-08-05 13:14:15", "2020-08-05 13:14:14", "1s after"}, + 23: {"2020-08-05 13:14:15", "2020-08-05 13:14:25", "10s before"}, + 24: {"2020-08-05 13:14:15", "2020-08-05 13:14:05", "10s after"}, } for index, test := range tests { @@ -107,13 +107,13 @@ func TestLanguage_SetResources2(t *testing.T) { input string // 输入值 expected string // 期望值 }{ - {"", ""}, - {"0", ""}, - {"0000-00-00", ""}, - {"00:00:00", ""}, + 0: {"", ""}, + 1: {"0", ""}, + 2: {"0000-00-00", ""}, + 3: {"00:00:00", ""}, - {"0000-00-00 00:00:00", ""}, - {"2021-08-05 13:14:15", ""}, + 4: {"0000-00-00 00:00:00", ""}, + 5: {"2021-08-05 13:14:15", ""}, } for index, test := range tests {