本文整理匯總了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)
}
}