Example #1
0
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")
}
Example #2
0
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)
	}
}