go_dreamfactory/utils/utils_test.go
2022-08-24 16:52:42 +08:00

40 lines
617 B
Go

package utils_test
import (
"fmt"
"go_dreamfactory/utils"
"testing"
"time"
)
func TestIsToday(t *testing.T) {
// fmt.Println(utils.IsToday(0))
tt := time.Unix(1658139742, 0)
fmt.Println(time.Now().Before(tt))
}
func TestSubTime(t *testing.T) {
fmt.Println(utils.IsAfterWeek(1657172915))
}
func TestRandom(t *testing.T) {
fmt.Println(utils.GenValidateCode(6))
}
func TestNumber(t *testing.T) {
for i := 0; i < 100; i++ {
fmt.Println(utils.Numbers(0, 99, 10))
}
}
func BenchmarkNumber(b *testing.B) {
b.Log("begin")
b.ReportAllocs()
for i := 0; i < b.N; i++ {
utils.Numbers(0, 1000, 10)
}
}