本文整理匯總了Golang中github.com/funny/utest.EqualNow函數的典型用法代碼示例。如果您正苦於以下問題:Golang EqualNow函數的具體用法?Golang EqualNow怎麽用?Golang EqualNow使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EqualNow函數的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_SyncPool_AllocSmall
func Test_SyncPool_AllocSmall(t *testing.T) {
pool := NewSyncPool(128, 1024, 2)
mem := pool.Alloc(64)
utest.EqualNow(t, len(mem), 64)
utest.EqualNow(t, cap(mem), 128)
pool.Free(mem)
}
示例3: Test_SyncPool_AllocLarge
func Test_SyncPool_AllocLarge(t *testing.T) {
pool := NewSyncPool(128, 1024, 2)
mem := pool.Alloc(2048)
utest.EqualNow(t, len(mem), 2048)
utest.EqualNow(t, cap(mem), 2048)
pool.Free(mem)
}
示例4: Test_Cmd
func Test_Cmd(t *testing.T) {
Register("lookup api", "save api time record to file", func(args []string) interface{} {
utest.EqualNow(t, args[0], "lookup api")
return 1
})
Register("lookup gc", "save gc summary to file", func(args []string) interface{} {
utest.EqualNow(t, args[0], "lookup gc")
return 2
})
Register("lookup heap ([0-2])", "save heap status to file", func(args []string) interface{} {
utest.EqualNow(t, args[1], "1")
return 3
})
n, ok := Process("lookup api")
utest.Assert(t, ok && n == 1, n)
Process("lookup gc")
n, ok = Process("lookup gc")
utest.Assert(t, ok && n == 2, n)
n, ok = Process("lookup heap 1")
utest.Assert(t, ok && n == 3, n)
}
示例5: Test_LockPool_AllocSlow
func Test_LockPool_AllocSlow(t *testing.T) {
pool := NewLockPool(128, 1024, 2, 1024)
mem := pool.classes[len(pool.classes)-1].Pop()
utest.EqualNow(t, cap(mem), 1024)
mem = pool.Alloc(1024)
utest.EqualNow(t, cap(mem), 1024)
}
示例6: Test_AtomPool_AllocSlow
func Test_AtomPool_AllocSlow(t *testing.T) {
pool := NewAtomPool(128, 1024, 2, 1024)
mem := pool.classes[len(pool.classes)-1].Pop()
utest.EqualNow(t, cap(mem), 1024)
utest.Assert(t, pool.classes[len(pool.classes)-1].head == 0)
mem = pool.Alloc(1024)
utest.EqualNow(t, cap(mem), 1024)
}
示例7: Test_Transfer
func Test_Transfer(t *testing.T) {
listener, err := net.Listen("tcp", "0.0.0.0:0")
utest.IsNilNow(t, err)
defer listener.Close()
go func() {
for {
conn, err := listener.Accept()
if err != nil {
continue
}
go func() {
defer conn.Close()
io.Copy(conn, conn)
}()
}
}()
for i := 0; i < 20; i++ {
conn, err := net.Dial("tcp", cfgGatewayAddr)
utest.IsNilNow(t, err)
defer conn.Close()
encryptedAddr, err := aes256cbc.EncryptString(string(cfgSecret), listener.Addr().String())
utest.IsNilNow(t, err)
_, err = conn.Write([]byte(encryptedAddr))
utest.IsNilNow(t, err)
_, err = conn.Write([]byte("\nabc"))
utest.IsNilNow(t, err)
code := make([]byte, 6)
_, err = io.ReadFull(conn, code)
utest.IsNilNow(t, err)
utest.EqualNow(t, string(code[:3]), string(codeOK))
utest.EqualNow(t, string(code[3:]), "abc")
for j := 0; j < 10000; j++ {
b1 := RandBytes(256)
_, err = conn.Write(b1)
utest.IsNilNow(t, err)
b2 := make([]byte, len(b1))
_, err = io.ReadFull(conn, b2)
utest.IsNilNow(t, err)
utest.EqualNow(t, b1, b2)
}
}
}
示例8: Test_ReadWrite
func Test_ReadWrite(t *testing.T) {
ReadWriteTest(t, 10000, func(r *Reader, w *Writer) {
b := RandBytes(256)
n, err := w.Write(b)
utest.IsNilNow(t, err)
utest.EqualNow(t, n, len(b))
c := make([]byte, len(b))
n, err = r.Read(c)
utest.IsNilNow(t, err)
utest.EqualNow(t, n, len(b))
utest.EqualNow(t, b, c)
})
}
示例9: 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)
}
}
示例10: Test_DialTimeout
func Test_DialTimeout(t *testing.T) {
oldTimeout := cfgDialTimeout
cfgDialTimeout = 10
defer func() {
cfgDialTimeout = oldTimeout
}()
listener, err := net.Listen("tcp", "0.0.0.0:0")
utest.IsNilNow(t, err)
defer listener.Close()
conn, err := net.Dial("tcp", cfgGatewayAddr)
utest.IsNilNow(t, err)
defer conn.Close()
encryptedAddr, err := aes256cbc.EncryptString("test", listener.Addr().String())
utest.IsNilNow(t, err)
_, err = conn.Write([]byte(encryptedAddr))
utest.IsNilNow(t, err)
_, err = conn.Write([]byte("\n"))
utest.IsNilNow(t, err)
code := make([]byte, 3)
_, err = io.ReadFull(conn, code)
utest.IsNilNow(t, err)
utest.EqualNow(t, string(code), string(codeDialTimeout))
}
示例11: Test_Buffer_ReadWrite
func Test_Buffer_ReadWrite(t *testing.T) {
var buf Buffer
for i := 0; i < 10000; i++ {
b := RandBytes(256)
buf.Grow(len(b))
n, err := buf.Write(b)
utest.IsNilNow(t, err)
utest.EqualNow(t, n, len(b))
c := make([]byte, len(b))
n, err = buf.Read(c)
utest.IsNilNow(t, err)
utest.EqualNow(t, n, len(b))
utest.EqualNow(t, b, c)
}
}
示例12: Test_Buffer_Uvarint
func Test_Buffer_Uvarint(t *testing.T) {
var buf = Buffer{Data: make([]byte, 10)}
v1 := uint64(rand.Int63n(0x7FFFFFFFFFFFFFFF))
buf.WriteUvarint(v1)
v2 := buf.ReadUvarint()
utest.EqualNow(t, v1, v2)
}
示例13: Test_Buffer_Uint24LE
func Test_Buffer_Uint24LE(t *testing.T) {
var buf = Buffer{Data: make([]byte, 10)}
v1 := uint32(rand.Intn(0xFFFFFF))
buf.WriteUint24LE(v1)
v2 := buf.ReadUint24LE()
utest.EqualNow(t, v1, v2)
}
示例14: Test_Buffer_IntLE
func Test_Buffer_IntLE(t *testing.T) {
var buf = Buffer{Data: make([]byte, 10)}
v1 := int(rand.Int63n(0x7FFFFFFFFFFFFFFF))
buf.WriteIntLE(v1)
v2 := buf.ReadIntLE()
utest.EqualNow(t, v1, v2)
}
示例15: Test_Buffer_Int8
func Test_Buffer_Int8(t *testing.T) {
var buf = Buffer{Data: make([]byte, 10)}
v1 := int8(rand.Intn(256))
buf.WriteInt8(v1)
v2 := buf.ReadInt8()
utest.EqualNow(t, v1, v2)
}