feat(Go-Tool):修改单测位置,添加lomuto查找第k小元素算法代码及其单测(分治法)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* @Author : huangzj
|
||||
* @Time : 2020/5/7 11:27
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
package timed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTimeIntervalUtil(t *testing.T) {
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetSecondsBefore(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetSecondsAfter(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetMinutesBefore(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetMinutesAfter(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetHoursBefore(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetHoursAfter(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetDaysBefore(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetDaysAfter(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetMonthsBefore(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetMonthsAfter(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetYearsBefore(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetYearsAfter(time.Now().Unix(), 10)))
|
||||
fmt.Print("\n\n")
|
||||
o1 := GetIntervalBetweenTimes(time.Now().Unix(), time.Now().AddDate(3, 2, 5).Add(5*time.Hour).Add(7*time.Minute).Add(10*time.Second).Unix())
|
||||
o2 := GetIntervalBetweenTimes(time.Now().AddDate(3, 2, 5).Add(5*time.Hour).Add(7*time.Minute).Add(10*time.Second).Unix(), time.Now().Unix())
|
||||
o3 := GetIntervalBetweenTimes(time.Now().Unix(), time.Now().AddDate(3, -2, 5).Add(5*time.Hour).Add(7*time.Minute).Add(10*time.Second).Unix())
|
||||
|
||||
fmt.Println(o1.IntervalYear, " y ", o1.IntervalMonth, " m ", o1.IntervalDay, " d ", o1.IntervalHour, " H ", o1.IntervalMinute, " mm ", o1.IntervalSecond, " ss ")
|
||||
fmt.Println(o2.IntervalYear, " y ", o2.IntervalMonth, " m ", o2.IntervalDay, " d ", o2.IntervalHour, " H ", o2.IntervalMinute, " mm ", o2.IntervalSecond, " ss ")
|
||||
fmt.Println(o3.IntervalYear, " y ", o3.IntervalMonth, " m ", o3.IntervalDay, " d ", o3.IntervalHour, " H ", o3.IntervalMinute, " mm ", o3.IntervalSecond, " ss ")
|
||||
o4 := GetIntervalBetweenTimesDetail(time.Now().Unix(), time.Now().AddDate(3, -2, 5).Add(5*time.Hour).Add(7*time.Minute).Add(10*time.Second).Unix())
|
||||
o5 := GetIntervalBetweenTimesDetail(time.Now().Unix(), time.Now().Unix())
|
||||
o6 := GetIntervalBetweenTimesDetail(time.Now().Unix(), time.Now().AddDate(3, 2, 5).Add(5*time.Hour).Add(7*time.Minute).Add(10*time.Second).Unix())
|
||||
|
||||
fmt.Println(o4.Year, " y ", o4.Month, " m ", o4.Week, " w ", o4.Day, " d ", o4.Hour, " H ", o4.Minute, " mm ", o4.Second, " ss ")
|
||||
fmt.Println(o5.Year, " y ", o5.Month, " m ", o5.Week, " w ", o5.Day, " d ", o5.Hour, " H ", o5.Minute, " mm ", o5.Second, " ss ")
|
||||
fmt.Println(o6.Year, " y ", o6.Month, " m ", o6.Week, " w ", o6.Day, " d ", o6.Hour, " H ", o6.Minute, " mm ", o6.Second, " ss ")
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* @Author : huangzj
|
||||
* @Time : 2020/5/7 13:35
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
package timed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTimeCompareUtil(t *testing.T) {
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(IsBefore(time.Now().Unix(), time.Now().AddDate(0, 0, 1).Unix()))
|
||||
fmt.Println(IsBefore(time.Now().Unix(), time.Now().AddDate(0, 0, -1).Unix()))
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(IsAfter(time.Now().Unix(), time.Now().AddDate(0, 0, -1).Unix()))
|
||||
fmt.Println(IsAfter(time.Now().Unix(), time.Now().AddDate(0, 0, 1).Unix()))
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(IsSameTime(time.Now().Unix(), time.Now().Unix()))
|
||||
fmt.Println(IsSameTime(time.Now().Unix(), time.Now().AddDate(0, 0, -1).Unix()))
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(IsDiffTime(time.Now().Unix(), time.Now().Unix()))
|
||||
fmt.Println(IsDiffTime(time.Now().Unix(), time.Now().AddDate(0, 0, -1).Unix()))
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(IsBetween(time.Now().Unix(), time.Now().Unix(), time.Now().Unix()))
|
||||
fmt.Println(IsBetween(time.Now().Unix(), time.Now().AddDate(0, 0, -1).Unix(), time.Now().AddDate(0, 0, 1).Unix()))
|
||||
fmt.Println(IsBetween(time.Now().Unix(), time.Now().AddDate(0, 0, 1).Unix(), time.Now().AddDate(0, 0, -1).Unix()))
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Author : huangzj
|
||||
* @Time : 2020/5/7 10:04
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
package timed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTimeFormatUtil(t *testing.T) {
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeDefaultFormatString(GetNowYearUnix()))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetTimeFormatString(GetNowHourUnix(), time.ANSIC))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Print(GetNowDefaultFormatString())
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetMonthFormatString(GetNowHourUnix()))
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetSimpleTimeFormatString(time.Now().Unix()))
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* @Author : huangzj
|
||||
* @Time : 2020/5/7 9:39
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
package timed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTimeStampUtil(t *testing.T) {
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetNowHourUnix())
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetNowUnix())
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetZeroHourUnix())
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetNowYearUnix())
|
||||
|
||||
fmt.Print("\n\n")
|
||||
fmt.Println(GetNowMonthUnix())
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user