本文整理汇总了Golang中testing.T.Nanosecond方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Nanosecond方法的具体用法?Golang T.Nanosecond怎么用?Golang T.Nanosecond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.Nanosecond方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPrepare
func TestPrepare(t *testing.T) {
buff.WriteString("\n\n\n========================================================\n")
buff.WriteString("TestPrepare start\n\n\n")
buff.WriteString("*************测试前的准备,新建测试用户,10司机账号+10个乘客账号****************\n\n\n")
head := "test head"
str := "/user/reg?userName=%v&mobile=%v&head=%v"
for i := 0; i < 10; i++ {
name := "driver" + strconv.Itoa(t.Nanosecond()) + strconv.Itoa(i)
mobile := "dm" + strconv.Itoa(t.Nanosecond()) + strconv.Itoa(i)
var vmap map[string]interface{}
s, err := ts.G(str, name, mobile, head)
vmap, _ = util.Json2Map(s)
uidSlice = append(uidSlice, vmap["data"])
writeString(s, err)
}
for i := 0; i < 10; i++ {
name := "passenger" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i)
mobile := "pm" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i)
var vmap map[string]interface{}
s, err := ts.G(str, name, mobile, head)
vmap, _ = util.Json2Map(s)
uidSlice = append(uidSlice, vmap["data"])
writeString(s, err)
}
buff.WriteString("TestPrepare end\n\n\n")
buff.WriteString("\n\n\n========================================================\n")
}
示例2: TestNanosecondsToUTCAndBack
func TestNanosecondsToUTCAndBack(t *testing.T) {
f := func(nsec int64) bool {
t := Unix(0, nsec).UTC()
ns := t.Unix()*1e9 + int64(t.Nanosecond())
return ns == nsec
}
f32 := func(nsec int32) bool { return f(int64(nsec)) }
cfg := &quick.Config{MaxCount: 10000}
// Try a small date first, then the large ones. (The span is only a few hundred years
// for nanoseconds in an int64.)
if err := quick.Check(f32, cfg); err != nil {
t.Fatal(err)
}
if err := quick.Check(f, cfg); err != nil {
t.Fatal(err)
}
}