本文整理匯總了Golang中github.com/funny/utest.IsNilNow函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsNilNow函數的具體用法?Golang IsNilNow怎麽用?Golang IsNilNow使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IsNilNow函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Test_QueryReader
func Test_QueryReader(t *testing.T) {
conn, err := Connect(TestConnParam)
utest.IsNilNow(t, err)
defer conn.Close()
var res DataReader
res, err = conn.QueryReader("SELECT * FROM test ORDER BY id ASC")
utest.IsNilNow(t, err)
defer res.Close()
i := 0
for {
row, err1 := res.FetchNext()
utest.IsNilNow(t, err1)
if row == nil {
break
}
utest.EqualNow(t, row[0].Int64(), int64(i))
utest.EqualNow(t, row[1].String(), strconv.Itoa(i))
i++
}
utest.EqualNow(t, i, 10)
}
示例2: Test_Execute
func Test_Execute(t *testing.T) {
param := TestConnParam
param.DbName = "mysql"
conn, err := Connect(param)
utest.IsNilNow(t, err)
defer conn.Close()
_, err = conn.Execute("CREATE DATABASE " + TestConnParam.DbName)
utest.IsNilNow(t, err)
_, err = conn.Execute("USE " + TestConnParam.DbName)
utest.IsNilNow(t, err)
_, err = conn.Execute(`CREATE TABLE test (
id INT PRIMARY KEY,
value VARCHAR(10)
)`)
utest.IsNilNow(t, err)
for i := 0; i < 10; i++ {
res, err := conn.Execute("INSERT INTO test VALUES(" + strconv.Itoa(i) + ",'" + strconv.Itoa(i) + "')")
utest.IsNilNow(t, err)
utest.EqualNow(t, res.RowsAffected(), 1)
}
}
示例3: Test_Connect
func Test_Connect(t *testing.T) {
conn, err := sql.Open("mysql", TestConnParam)
utest.IsNilNow(t, err)
err = conn.Close()
utest.IsNilNow(t, err)
}
示例4: Test_Query
func Test_Query(t *testing.T) {
conn, err := sql.Open("mysql", TestConnParam)
utest.IsNilNow(t, err)
defer conn.Close()
var res *sql.Rows
res, err = conn.Query("SELECT * FROM test ORDER BY id ASC")
utest.IsNilNow(t, err)
defer res.Close()
i := 0
for res.Next() {
var (
id int64
value string
)
err := res.Scan(&id, &value)
utest.IsNilNow(t, err)
utest.Equal(t, id, int64(i))
utest.Equal(t, value, strconv.Itoa(i))
i++
}
utest.Equal(t, i, 10)
}
示例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))
utest.IsNilNow(t, err)
defer conn.Close()
_, err = conn.Exec("CREATE DATABASE " + TestConnEnv.DbName)
utest.IsNilNow(t, err)
_, err = conn.Exec("USE " + TestConnEnv.DbName)
utest.IsNilNow(t, err)
_, err = conn.Exec(`CREATE TABLE test (
id INT PRIMARY KEY,
value VARCHAR(10)
)`)
utest.IsNilNow(t, err)
for i := 0; i < 10; i++ {
res, err := conn.Exec("INSERT INTO test VALUES(" + strconv.Itoa(i) + ",'" + strconv.Itoa(i) + "')")
utest.IsNilNow(t, err)
num, _ := res.RowsAffected()
utest.Equal(t, num, 1)
}
}
示例6: Test_Clean
func Test_Clean(t *testing.T) {
conn, err := Connect(TestConnParam)
utest.IsNilNow(t, err)
defer conn.Close()
_, err = conn.Execute("DROP DATABASE " + TestConnParam.DbName)
utest.IsNilNow(t, err)
}
示例7: Test_Clean
func Test_Clean(t *testing.T) {
conn, err := sql.Open("mysql", TestConnParam)
utest.IsNilNow(t, err)
defer conn.Close()
_, err = conn.Exec("DROP DATABASE " + TestConnEnv.DbName)
utest.IsNilNow(t, err)
}
示例8: Test_ReadWrite_Uint24BE
func Test_ReadWrite_Uint24BE(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
v1 := uint32(rand.Intn(0xFFFFFF))
w.WriteUint24BE(v1)
utest.IsNilNow(t, w.Error())
v2 := r.ReadUint24BE()
utest.IsNilNow(t, r.Error())
utest.EqualNow(t, v1, v2)
})
}
示例9: Test_ReadWrite_IntLE
func Test_ReadWrite_IntLE(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
v1 := int(rand.Int63n(0x7FFFFFFFFFFFFFFF))
w.WriteIntLE(v1)
utest.IsNilNow(t, w.Error())
v2 := r.ReadIntLE()
utest.IsNilNow(t, r.Error())
utest.EqualNow(t, v1, v2)
})
}
示例10: Test_ReadWrite_Float64LE
func Test_ReadWrite_Float64LE(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
v1 := rand.NormFloat64()
w.WriteFloat64LE(v1)
utest.IsNilNow(t, w.Error())
v2 := r.ReadFloat64LE()
utest.IsNilNow(t, r.Error())
utest.EqualNow(t, v1, v2)
})
}
示例11: Test_BadAddr
func Test_BadAddr(t *testing.T) {
conn, err := net.Dial("tcp", cfgGatewayAddr)
utest.IsNilNow(t, err)
defer conn.Close()
_, err = conn.Write([]byte("abc\n"))
utest.IsNilNow(t, err)
code := make([]byte, 3)
_, err = io.ReadFull(conn, code)
utest.IsNilNow(t, err)
utest.EqualNow(t, string(code), string(codeBadAddr))
}
示例12: Test_ReadWrite_String
func Test_ReadWrite_String(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
b := string(RandBytes(256))
w.WriteString(b)
utest.IsNilNow(t, w.Error())
c := r.ReadString(len(b))
utest.IsNilNow(t, r.Error())
utest.EqualNow(t, b, c)
})
}
示例13: ObjectTest
func ObjectTest(t *testing.T, session *Session) {
for i := 0; i < 2000; i++ {
msg1 := RandObject()
err := session.Send(&msg1)
utest.IsNilNow(t, err)
var msg2 TestObject
err = session.Receive(&msg2)
utest.IsNilNow(t, err)
utest.EqualNow(t, msg1, msg2)
}
}
示例14: BytesTest
func BytesTest(t *testing.T, session *Session) {
for i := 0; i < 2000; i++ {
msg1 := RandBytes(512)
err := session.Send(msg1)
utest.IsNilNow(t, err)
var msg2 = make([]byte, len(msg1))
err = session.Receive(msg2)
utest.IsNilNow(t, err)
utest.EqualNow(t, msg1, msg2)
}
}
示例15: Test_BadReq1
func Test_BadReq1(t *testing.T) {
conn, err := net.Dial("tcp", cfgGatewayAddr)
utest.IsNilNow(t, err)
defer conn.Close()
err = conn.(*net.TCPConn).CloseWrite()
utest.IsNilNow(t, err)
code := make([]byte, 3)
_, err = io.ReadFull(conn, code)
utest.IsNilNow(t, err)
utest.EqualNow(t, string(code), string(codeBadReq))
}