1 Star 0 Fork 64

liuzw3018/carbon

forked from dromara/carbon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_test.go 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
package carbon
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCarbon_SetTestNow(t *testing.T) {
assert := assert.New(t)
testNow := Parse("2020-08-05")
assert.Equal("2020-08-04", SetTestNow(testNow).Yesterday().ToDateString(), "It should be equal to 2020-08-05")
assert.Equal("2020-08-05", SetTestNow(testNow).Now().ToDateString(), "It should be equal to 2020-08-05")
assert.Equal("2020-08-06", SetTestNow(testNow).Tomorrow().ToDateString(), "It should be equal to 2020-08-05")
}
func TestCarbon_ClearTestNow(t *testing.T) {
assert := assert.New(t)
datetime := "2020-08-05"
testNow := Parse(datetime)
assert.Equal(Now().ToDateString(), ClearTestNow().Now().ToDateString())
assert.Equal(Now().ToDateString(), SetTestNow(testNow).ClearTestNow().Now().ToDateString())
}
func TestCarbon_HasTestNow(t *testing.T) {
assert := assert.New(t)
datetime := "2020-08-05"
testNow := Parse(datetime)
assert.Equal(false, HasTestNow(), "It should be equal to false")
assert.Equal(false, Now().HasTestNow(), "It should be equal to false")
assert.Equal(true, SetTestNow(testNow).HasTestNow(), "It should be equal to true")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/liuzw3018/carbon.git
git@gitee.com:liuzw3018/carbon.git
liuzw3018
carbon
carbon
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385