1 Star 0 Fork 9

qaz9877/rboot

forked from Gitee 极速下载/rboot 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
timing_test.go 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
G.H 提交于 2021-04-21 15:00 . add timing.go
package rboot
import (
"fmt"
"testing"
"time"
)
var testTimer = NewTimer(1*time.Hour, "test", func() {
fmt.Println("test timer")
})
func TestTiming_Timer(t *testing.T) {
t.Log("endtime1", testTimer.EndTime())
testTimer.Reset(1 * time.Second)
t.Log("endtime2", testTimer.EndTime())
t.Log(testTimer.Name())
time.Sleep(2 * time.Second)
}
var testTicker = NewTicker(time.Second, "test", func() {
fmt.Println("test ticker")
})
func TestTiming_Ticker(t *testing.T) {
t.Log("name", testTicker.Name())
t.Logf("next %d -- %v", testTicker.Count(), testTicker.NextTime())
time.Sleep(2 * time.Second)
t.Logf("next %d -- %v", testTicker.Count(), testTicker.NextTime())
testTicker.Stop()
t.Logf("next %d -- %v", testTicker.Count(), testTicker.NextTime())
time.Sleep(time.Second)
}
func TestStrToDuration(t *testing.T) {
d, err := StrToDuration(1, "小时")
if err != nil {
t.Error(err)
}
t.Log("小时", int64(d))
d, err = StrToDuration(1, "分钟")
if err != nil {
t.Error(err)
}
t.Log("分钟", int64(d))
d, err = StrToDuration(1, "秒钟")
if err != nil {
t.Error(err)
}
t.Log("秒钟", int64(d))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qaz9877/rboot.git
git@gitee.com:qaz9877/rboot.git
qaz9877
rboot
rboot
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385