本文整理匯總了Golang中github.com/funny/unitest.Pass函數的典型用法代碼示例。如果您正苦於以下問題:Golang Pass函數的具體用法?Golang Pass怎麽用?Golang Pass使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Pass函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Test_QueryReader
func Test_QueryReader(t *testing.T) {
conn, err := Connect(TestConnParam)
unitest.NotError(t, err)
defer conn.Close()
var res DataReader
res, err = conn.QueryReader("SELECT * FROM test ORDER BY id ASC")
unitest.NotError(t, err)
defer res.Close()
i := 0
for {
row, err1 := res.FetchNext()
unitest.NotError(t, err1)
if row == nil {
break
}
unitest.Pass(t, row[0].Int64() == int64(i))
unitest.Pass(t, row[1].String() == strconv.Itoa(i))
i++
}
unitest.Pass(t, i == 10)
}
示例2: MemPoolTest
func MemPoolTest(t *testing.T, total, min, max int) {
pool := NewBufferPool(total, min, max)
for i := min; i <= max; i++ {
min1 := (i-1)*1024 + 1
max1 := i * 1024
b1 := pool.alloc(min1, min1)
b2 := pool.alloc(max1, max1)
unitest.Pass(t, cap(b1.Data) == max1)
unitest.Pass(t, cap(b2.Data) == max1)
b1.Free()
b2.Free()
}
rand.Seed(time.Now().UnixNano())
for i := 0; i < 100000; i++ {
size := (rand.Intn(max-min+1) + min) * 1024
b := pool.alloc(size, size)
b.Free()
}
/*
for _, class := range pool.classes {
unitest.Pass(t, class.length == class.maxlen)
}
*/
}
示例3: Test_Query
func Test_Query(t *testing.T) {
conn, err := sql.Open("mysql", TestConnParam)
unitest.NotError(t, err)
defer conn.Close()
var res *sql.Rows
res, err = conn.Query("SELECT * FROM test ORDER BY id ASC")
unitest.NotError(t, err)
defer res.Close()
i := 0
for res.Next() {
var (
id int64
value string
)
err := res.Scan(&id, &value)
unitest.NotError(t, err)
unitest.Pass(t, id == int64(i))
unitest.Pass(t, value == strconv.Itoa(i))
i++
}
unitest.Pass(t, i == 10)
}
示例4: Test_Execute
func Test_Execute(t *testing.T) {
param := TestConnParam
param.DbName = "mysql"
conn, err := Connect(param)
unitest.NotError(t, err)
defer conn.Close()
_, err = conn.Execute("CREATE DATABASE " + TestConnParam.DbName)
unitest.NotError(t, err)
_, err = conn.Execute("USE " + TestConnParam.DbName)
unitest.NotError(t, err)
_, err = conn.Execute(`CREATE TABLE test (
id INT PRIMARY KEY,
value VARCHAR(10)
)`)
unitest.NotError(t, err)
for i := 0; i < 10; i++ {
res, err := conn.Execute("INSERT INTO test VALUES(" + strconv.Itoa(i) + ",'" + strconv.Itoa(i) + "')")
unitest.NotError(t, err)
unitest.Pass(t, res.RowsAffected() == 1)
}
}
示例5: Test_Execute
func Test_Execute(t *testing.T) {
param := TestConnEnv
param.DbName = "mysql"
name, _ := json.Marshal(param)
conn, err := sql.Open("mysql", string(name))
unitest.NotError(t, err)
defer conn.Close()
_, err = conn.Exec("CREATE DATABASE " + TestConnEnv.DbName)
unitest.NotError(t, err)
_, err = conn.Exec("USE " + TestConnEnv.DbName)
unitest.NotError(t, err)
_, err = conn.Exec(`CREATE TABLE test (
id INT PRIMARY KEY,
value VARCHAR(10)
)`)
unitest.NotError(t, err)
for i := 0; i < 10; i++ {
res, err := conn.Exec("INSERT INTO test VALUES(" + strconv.Itoa(i) + ",'" + strconv.Itoa(i) + "')")
unitest.NotError(t, err)
num, _ := res.RowsAffected()
unitest.Pass(t, num == 1)
}
}
示例6: Test_Simple
func Test_Simple(t *testing.T) {
backend, err := StartEchoBackend()
unitest.NotError(t, err)
gateway := StartTestGateway(t, backend.Listener().Addr().String())
gatewayAddr := gateway.server.Listener().Addr().String()
client, err := link.Connect("tcp://"+gatewayAddr, link.Packet(link.Uint16BE), link.Bytes())
unitest.NotError(t, err)
for i := 0; i < 10000; i++ {
msg1 := RandBytes(1024)
err1 := client.Send(msg1)
unitest.NotError(t, err1)
var msg2 []byte
err2 := client.Receive(&msg2)
unitest.NotError(t, err2)
if bytes.Equal(msg1, msg2) == false {
t.Log(i, msg1, msg2)
t.Fail()
}
unitest.Pass(t, bytes.Equal(msg1, msg2))
}
client.Close()
gateway.Stop()
backend.Stop()
time.Sleep(time.Second * 2)
MakeSureSessionGoroutineExit(t)
}
示例7: Test_PHP_HTTP
func Test_PHP_HTTP(t *testing.T) {
result, err := PHP(`
$r = $client->Call("Arith.Multiply", array('A'=>7, 'B'=>8));
echo $r->result;
`)
unitest.NotError(t, err)
unitest.Pass(t, result == "56")
}
示例8: Test_PHP_Error
func Test_PHP_Error(t *testing.T) {
rpcErr, err := PHP(`
$r = $client->Call("Arith.GetError");
echo $r->error;
`)
unitest.NotError(t, err)
unitest.Pass(t, rpcErr == "Error!")
}
示例9: Test_Prepare
func Test_Prepare(t *testing.T) {
conn, err := sql.Open("mysql", TestConnParam)
unitest.NotError(t, err)
defer conn.Close()
var (
stmt *sql.Stmt
res sql.Result
reader *sql.Rows
)
stmt, err = conn.Prepare("SELECT * FROM test ORDER BY id ASC")
unitest.NotError(t, err)
reader, err = stmt.Query()
unitest.NotError(t, err)
i := 0
for reader.Next() {
var (
id int64
value string
)
err := reader.Scan(&id, &value)
unitest.NotError(t, err)
unitest.Pass(t, id == int64(i))
unitest.Pass(t, value == strconv.Itoa(i))
i++
}
unitest.Pass(t, i == 10)
stmt.Close()
stmt, err = conn.Prepare("INSERT INTO test VALUES(?, ?)")
unitest.NotError(t, err)
res, err = stmt.Exec(10, "10")
unitest.NotError(t, err)
num, _ := res.RowsAffected()
unitest.Pass(t, num == 1)
stmt.Close()
}
示例10: Test_Prepare
func Test_Prepare(t *testing.T) {
conn, err := Connect(TestConnParam)
unitest.NotError(t, err)
defer conn.Close()
var (
stmt *Stmt
res Result
table DataTable
reader DataReader
)
stmt, err = conn.Prepare("SELECT * FROM test ORDER BY id ASC")
unitest.NotError(t, err)
table, err = stmt.QueryTable()
unitest.NotError(t, err)
rows := table.Rows()
unitest.Pass(t, len(rows) == 10)
for i := 0; i < 10; i++ {
unitest.Pass(t, rows[i][0].Int64() == int64(i))
unitest.Pass(t, rows[i][1].String() == strconv.Itoa(i))
}
reader, err = stmt.QueryReader()
unitest.NotError(t, err)
i := 0
for {
row, err1 := reader.FetchNext()
unitest.NotError(t, err1)
if row == nil {
break
}
unitest.Pass(t, row[0].Int64() == int64(i))
unitest.Pass(t, row[1].String() == strconv.Itoa(i))
i++
}
unitest.Pass(t, i == 10)
stmt.Close()
stmt, err = conn.Prepare("INSERT INTO test VALUES(?, ?)")
unitest.NotError(t, err)
stmt.BindInt(10)
stmt.BindText("10")
res, err = stmt.Execute()
unitest.NotError(t, err)
unitest.Pass(t, res.RowsAffected() == 1)
stmt.Close()
}
示例11: Test_QueryTable
func Test_QueryTable(t *testing.T) {
conn, err := Connect(TestConnParam)
unitest.NotError(t, err)
defer conn.Close()
var res DataTable
res, err = conn.QueryTable("SELECT * FROM test ORDER BY id ASC")
unitest.NotError(t, err)
rows := res.Rows()
unitest.Pass(t, len(rows) == 10)
for i := 0; i < 10; i++ {
unitest.Pass(t, rows[i][0].Int64() == int64(i))
unitest.Pass(t, rows[i][1].String() == strconv.Itoa(i))
}
}
示例12: Test_Connect
func Test_Connect(t *testing.T) {
param := TestConnParam
param.DbName = "mysql"
conn, err := Connect(param)
unitest.NotError(t, err)
conn.Close()
unitest.Pass(t, conn.IsClosed())
}
示例13: Test_Go_TCP
func Test_Go_TCP(t *testing.T) {
var client, err = Dial("tcp", "127.0.0.1:23456")
if err != nil {
log.Fatal("Dialing:", err)
}
var reply int
err = client.Call("Arith.Multiply", &Args{7, 8}, &reply)
unitest.NotError(t, err)
unitest.Pass(t, reply == 56)
}
示例14: Test_Uint32BE
func Test_Uint32BE(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
v1 := uint32(rand.Intn(0xFFFFFFFF))
w.WriteUint32BE(v1)
w.Flush()
unitest.NotError(t, w.Error())
v2 := r.ReadUint32BE()
unitest.NotError(t, r.Error())
unitest.Pass(t, v1 == v2)
})
}
示例15: Test_Float64LE
func Test_Float64LE(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
v1 := rand.NormFloat64()
w.WriteFloat64LE(v1)
w.Flush()
unitest.NotError(t, w.Error())
v2 := r.ReadFloat64LE()
unitest.NotError(t, r.Error())
unitest.Pass(t, v1 == v2)
})
}