本文整理汇总了Golang中github.com/bronze1man/kmg/kmgTest.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestMustNewPackageFromImportPath
func TestMustNewPackageFromImportPath(ot *testing.T) {
pkg := kmgGoSource.MustNewPackageFromImportPath("github.com/bronze1man/kmg/kmgReflect")
kmgTest.Equal(pkg.PkgPath(), "github.com/bronze1man/kmg/kmgReflect")
pkg = kmgGoSource.MustNewPackageFromImportPath("go/doc")
kmgTest.Equal(pkg.PkgPath(), "go/doc")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:kmgReflectV2_test.go
示例2: TestParseImportPath
func TestParseImportPath(ot *testing.T) {
importPathList := parseImportPath("<nil>", []byte(`
/*
import (
"github.com/bronze1man/kmg/kmgView/webResource/bootstrap"
"boostrap"
)
*/
`))
kmgTest.Equal(importPathList, []string{
"github.com/bronze1man/kmg/kmgView/webResource/bootstrap",
"boostrap",
})
importPathList = parseImportPath("<nil>", []byte(`
/*
*/
`))
kmgTest.Equal(importPathList, nil)
importPathList = parseImportPath("<nil>", []byte(`
/*
*/
/*
import (
"github.com/bronze1man/kmg/kmgView/webResource/bootstrap"
"boostrap"
)
*/
`))
kmgTest.Equal(importPathList, nil)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:32,代码来源:parseImportPath_test.go
示例3: TestPeriodList
func TestPeriodList(ot *testing.T) {
itemList := ScratchItemList3{
[]int{1, 2},
[]int{2, 3},
[]int{3, 4},
}
periodList := PeriodList{
{
Period: Period{Start: MustFromMysqlFormat("2001-01-00 23:30:00"), End: MustFromMysqlFormat("2001-01-01 23:30:00")},
OriginIndex: 0,
},
{
Period: Period{Start: MustFromMysqlFormat("2001-01-03 23:30:00"), End: MustFromMysqlFormat("2001-01-04 23:30:00")},
OriginIndex: 1,
},
{
Period: Period{Start: MustFromMysqlFormat("2001-01-02 23:30:00"), End: MustFromMysqlFormat("2001-01-03 23:30:00")},
OriginIndex: 2,
},
}
periodList.Sort()
i, exist := periodList.SelectFromTime(MustFromMysqlFormat("2001-01-01 23:00:00"))
kmgTest.Equal(exist, true)
kmgTest.Equal(itemList[i], []int{1, 2})
i, exist = periodList.SelectFromTime(MustFromMysqlFormat("2001-01-03 23:00:00"))
kmgTest.Equal(exist, true)
kmgTest.Equal(itemList[i], []int{3, 4})
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:28,代码来源:Period3_test.go
示例4: TestFileChangeCacheOneFile
func TestFileChangeCacheOneFile(t *testing.T) {
//可以递归 遍历文件
//缓存数据文件不存在,没有问题
//指定的文件不存在,也没有问题
callLog := make([]string, 32)
//指定的文件不存在
kmgFile.MustDeleteFile(getFileChangeCachePath("test_file_change_cache"))
kmgFile.MustDeleteFile("testFile/notExist")
MustFileChangeCache("test_file_change_cache", []string{
"testFile/notExist",
}, func() {
callLog[1] = "notExist"
kmgFile.MustWriteFileWithMkdir("testFile/notExist", []byte("1"))
})
kmgTest.Equal(callLog[1], "notExist")
MustFileChangeCache("test_file_change_cache", []string{
"testFile/notExist",
}, func() {
callLog[2] = "notExist"
})
kmgTest.Equal(callLog[2], "")
time.Sleep(time.Second * 1)
kmgFile.MustWriteFile("testFile/notExist", []byte("2"))
MustFileChangeCache("test_file_change_cache", []string{
"testFile/notExist",
}, func() {
callLog[3] = "notExist"
})
kmgTest.Equal(callLog[3], "notExist")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:34,代码来源:FileChangeCache_test.go
示例5: TestKmgPageWithDb
func TestKmgPageWithDb(ot *testing.T) {
setupDb()
kmgSql.MustExec("DROP TABLE IF EXISTS `kmgSql_test_table`")
kmgSql.MustExec("CREATE TABLE `kmgSql_test_table` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Info` varchar(255) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
kmgSql.MustSetTableDataYaml(`
kmgSql_test_table:
- Id: 1
- Id: 2
- Id: 3
- Id: 4
`)
pager := kmgPage.CreateFromSelectCommand(kmgPage.CreateFromSelectCommandRequest{
Select: MysqlAst.NewSelectCommand().From("kmgSql_test_table"),
Url: "/?n=a",
ItemPerPage: 2,
CurrentPage: 1,
})
kmgTest.Equal(len(pager.Data), 2)
pager = kmgPage.CreateFromSelectCommand(kmgPage.CreateFromSelectCommandRequest{
Select: MysqlAst.NewSelectCommand().From("kmgSql_test_table"),
Url: "/?n=a",
})
kmgTest.Equal(len(pager.Data), 4)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:25,代码来源:kmgPage_test.go
示例6: TestMustTlsTestListen
func TestMustTlsTestListen(ot *testing.T) {
listener := kmgCrypto.MustTlsTestListen(":0")
defer listener.Close()
listenAddr := kmgNet.MustGetLocalAddrFromListener(listener)
waitAcceptChan := make(chan int)
go func() {
defer func() { waitAcceptChan <- 1 }()
conn, err := listener.Accept()
kmgTest.Equal(err, nil)
defer conn.Close()
//此处开始检测两条连接是否连在了一起
result, err := ioutil.ReadAll(conn)
kmgTest.Equal(err, nil)
kmgTest.Ok(bytes.Equal(result, []byte(`hello world`)))
}()
conn, err := tls.Dial("tcp", listenAddr, &tls.Config{
InsecureSkipVerify: true,
})
kmgTest.Equal(err, nil)
defer conn.Close()
_, err = conn.Write([]byte(`hello world`))
kmgTest.Equal(err, nil)
conn.Close()
<-waitAcceptChan
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:25,代码来源:TlsTestListen_test.go
示例7: TestDurationFormat
func TestDurationFormat(ot *testing.T) {
kmgTest.Equal(DurationFormat(time.Second), "1s")
kmgTest.Equal(DurationFormat(1000*time.Second), "16m40s")
kmgTest.Equal(DurationFormat(12345*time.Millisecond), "12.34s")
kmgTest.Equal(DurationFormat(1234*time.Microsecond), "1.23ms")
kmgTest.Equal(DurationFormat(1234*time.Nanosecond), "1.23µs")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:DuringFormat_test.go
示例8: TestGetPeriodFromSortedList
func TestGetPeriodFromSortedList(ot *testing.T) {
SortedList := []Period{
{
Start: MustFromMysqlFormat("2001-01-01 00:00:00"),
End: MustFromMysqlFormat("2001-01-01 01:00:00"),
},
{
Start: MustFromMysqlFormat("2001-01-01 02:00:00"),
End: MustFromMysqlFormat("2001-01-01 03:00:00"),
},
{
Start: MustFromMysqlFormat("2001-01-01 03:00:00"),
End: MustFromMysqlFormat("2001-01-01 04:00:00"),
},
}
for _, testcase := range []struct {
t time.Time
i int
ok bool
}{
{MustFromMysqlFormat("2001-01-00 23:30:00"), 0, false},
{MustFromMysqlFormat("2001-01-01 00:30:00"), 0, true},
{MustFromMysqlFormat("2001-01-01 03:00:00"), 2, true},
{MustFromMysqlFormat("2001-01-01 04:30:00"), 0, false},
} {
i, ok := GetPeriodFromSortedList(testcase.t, SortedList)
kmgTest.Equal(i, testcase.i)
kmgTest.Equal(ok, testcase.ok)
}
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:30,代码来源:Period_test.go
示例9: benchmarkScanCallback
func benchmarkScanCallback() {
N := 1000 * 100
MustFlushDbV2()
t := time.Now()
pairList := make([]KeyValuePair, N)
for i := 0; i < N; i++ {
pairList[i].Key = "test_" + strconv.Itoa(i)
pairList[i].Value = "abc"
}
MustMSet(pairList)
fmt.Println(time.Since(t)) //386.265848ms
t = time.Now()
num := 0
err := ScanCallback("*", func(key string) error {
num++
return nil
}) //169.983354ms
fmt.Println(time.Since(t))
kmgTest.Equal(err, nil)
kmgTest.Equal(num, N)
t = time.Now()
sList, err := Keys("*") //138.565292ms
fmt.Println(time.Since(t))
kmgTest.Equal(err, nil)
kmgTest.Equal(len(sList), N)
MustFlushDbV2()
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:27,代码来源:db_test.go
示例10: TestTap
func TestTap(ot *testing.T) {
tap, err := NewTap("")
if os.IsPermission(err) {
ot.Skip("you need root permission to run this test.")
return
}
kmgTest.Equal(err, nil)
defer tap.Close()
kmgTest.Equal(tap.GetDeviceType(), DeviceTypeTap)
err = kmgCmd.CmdString("ifconfig " + tap.Name() + " 10.209.34.1 up").GetExecCmd().Run()
kmgTest.Equal(err, nil)
/*
cmd := kmgCmd.NewOsStdioCmdString("ping 10.0.0.2")
err = cmd.Start()
t.Equal(err, nil)
defer cmd.Process.Kill()
buf := make([]byte, 4096)
n, err := tun.Read(buf)
t.Equal(err, nil)
t.Ok(n > 0)
tun2, err := NewTap("")
t.Equal(err, nil)
defer tun2.Close()
*/
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:28,代码来源:tun_test.go
示例11: TestAuthPap
func TestAuthPap(ot *testing.T) {
//AccessRequest
inBytes := []byte{0x1, 0xef, 0x0, 0x8e, 0x94, 0xb, 0x18, 0xaf, 0xa, 0xb6, 0x12, 0xf5, 0x24, 0x4, 0x94, 0xbe, 0x18, 0xbc, 0x7, 0x4d,
0x1, 0x4, 0x72, 0x48, 0x3d, 0x6, 0x0, 0x0, 0x0, 0x5, 0x6, 0x6, 0x0, 0x0, 0x0, 0x2, 0x5, 0x6, 0x0, 0x0, 0x0, 0x10, 0x57,
0xf, 0x69, 0x6f, 0x73, 0x5f, 0x78, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x73, 0x6b, 0x4, 0x6, 0xa, 0x1, 0x1, 0x5, 0x1e,
0xf, 0x31, 0x30, 0x2e, 0x31, 0x2e, 0x31, 0x2e, 0x35, 0x5b, 0x35, 0x30, 0x30, 0x5d, 0x1f, 0x10, 0x31, 0x30, 0x2e, 0x31,
0x2e, 0x31, 0x2e, 0x37, 0x30, 0x5b, 0x35, 0x30, 0x30, 0x5d, 0x20, 0xc, 0x73, 0x74, 0x72, 0x6f, 0x6e, 0x67, 0x53, 0x77,
0x61, 0x6e, 0x2, 0x12, 0x8d, 0x7, 0xc2, 0xc0, 0xa4, 0x2, 0x2c, 0xed, 0x8e, 0x69, 0x5b, 0x9e, 0x25, 0x77, 0xe5, 0xd, 0x50,
0x12, 0x39, 0x5c, 0xaa, 0x3e, 0x6d, 0x23, 0xea, 0xb5, 0x86, 0xc1, 0x3, 0x2d, 0x9d, 0x5c, 0x19, 0xca}
server := server{
handler: Handler{
Auth: func(username string) (password string, exist bool) {
if username != "rH" {
panic(`username!="rH"`)
}
return "O6", true
},
},
}
inPac, err := DecodeRequestPacket([]byte("sEcReT"), inBytes)
kmgTest.Equal(inPac.GetPassword(), "O6")
kmgTest.Ok(err == nil)
outPac := server.PacketHandler(inPac)
kmgTest.Equal(outPac.Code, CodeAccessAccept)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:25,代码来源:Auth_test.go
示例12: TestRsaOpensslVerify
func TestRsaOpensslVerify(ot *testing.T) {
var err error
privateKey := []byte(`-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDA4E8H2qksOnCSoBkq+HH3Dcu0/iWt3iNcpC/BCg0F8tnMhF1Q
OQ98cRUM8eeI9h+S6g/5UmO4hBKMOP3vg/u7kI0ujrCN1RXpsrTbWaqry/xTDgTM
8HkKkNhRSyDJWJVye0mPgbvVnx76en+K6LLzDaQH8yKI/dbswSq65XFcIwIDAQAB
AoGAU+uFF3LBdtf6kSGNsc+lrovXHWoTNOJZWn6ptIFOB0+SClVxUG1zWn7NXPOH
/WSxejfTOXTqpKb6dv55JpSzmzf8fZphVE9Dfr8pU68x8z5ft4yv314qLXFDkNgl
MeQht4n6mo1426dyoOcCfmWc5r7LQCi7WmOsKvATe3nzk/kCQQDp1gyDIVAbUvwe
tpsxZpAd3jLD49OVHUIy2eYGzZZLK3rA1uNWWZGsjrJQvfGf+mW+/zeUMYPBpk0B
XYqlgHJNAkEA0yhhu/2SPJYxIS9umCry1mj7rwji5O2qVSssChFyOctcbysbNJLH
qoF7wumr9PAjjWFWdmCzzEJyxMMurL3gLwJBAIEoeNrJQL0G9jlktY3wz7Ofsrye
j5Syh4kc8EBbuCMnDfOL/iAI8zyzyOxuLhMmNKLtx140h0kkOS6C430M2JUCQCnM
a5RX/JOrs2v7RKwwjENvIqsiWi+w8C/NzPjtPSw9mj2TTd5ZU9bnrMUHlnd09cSt
yPzD5bOAT9GtRVcCexcCQBxXHRleikPTJC90GqrC2l6erYJaiSOtv6QYIh0SEDVm
1o6Whw4FEHUPqMW0Z5PobPFiEQT+fFR02xU3NJrjYy0=
-----END RSA PRIVATE KEY-----`)
publicKey := []byte(`-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA4E8H2qksOnCSoBkq+HH3Dcu0/
iWt3iNcpC/BCg0F8tnMhF1QOQ98cRUM8eeI9h+S6g/5UmO4hBKMOP3vg/u7kI0ujr
CN1RXpsrTbWaqry/xTDgTM8HkKkNhRSyDJWJVye0mPgbvVnx76en+K6LLzDaQH8yK
I/dbswSq65XFcIwIDAQAB
-----END PUBLIC KEY-----`)
signed := kmgBase64.MustStdBase64DecodeStringToByte(`AqDW/m+aGn2kFo54Bt5XnXniBDtCxmPS6FMfHrLizh7d4jgnz4LbwBfRvXywI6HEKgr7Vk37duTM8P+XqmT+uQU2R1h4nRwOf2fCstXmgeD3qGk/XI+XMafgMkTnV/B9dOXpdUbxEpL1fDhmo7A6J0rcJotG7TP7i1zcvY4oiXk=`)
msg := []byte("this is a test!")
rsaKey, err := RsaParseOpensslPrivateKey(privateKey)
s, err := RsaOpensslSign(rsaKey, crypto.SHA1, msg)
kmgTest.Equal(err, nil)
kmgTest.Equal(s, signed)
rsapk, err := RsaParseOpensslPublicKey(publicKey)
kmgTest.Equal(err, nil)
err = RsaOpensslVerify(rsapk, crypto.SHA1, msg, signed)
kmgTest.Equal(err, nil)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:35,代码来源:rsa_test.go
示例13: TestUrlv
func TestUrlv(t *testing.T) {
kmgTest.Equal(Urlv("abcd"), "abcd")
kmgTest.Equal(Urlv("abcd哈"), "abcd%E5%93%88")
kmgTest.Equal(Urlv("abcd "), "abcd%20")
kmgTest.Equal(Urlv("abcd.abc"), "abcd.abc")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:kmgXss_test.go
示例14: TestFileChangeCacheOneDir
func TestFileChangeCacheOneDir(t *testing.T) {
callLog := make([]string, 32)
//递归可用
kmgFile.MustDeleteFile(getFileChangeCachePath("test_file_change_cache"))
kmgFile.MustMkdirAll("testFile/d1/d2")
kmgFile.MustWriteFile("testFile/d1/d2/f3", []byte("1"))
MustFileChangeCache("test_file_change_cache", []string{
"testFile/d1",
}, func() {
callLog[3] = "f3"
})
kmgTest.Equal(callLog[3], "f3")
MustFileChangeCache("test_file_change_cache", []string{
"testFile/d1",
}, func() {
callLog[4] = "f3"
})
kmgTest.Equal(callLog[4], "")
time.Sleep(time.Second * 1)
kmgFile.MustWriteFile("testFile/d1/d2/f3", []byte("2"))
MustFileChangeCache("test_file_change_cache", []string{
"testFile/d1",
}, func() {
callLog[5] = "f3"
})
kmgTest.Equal(callLog[5], "f3")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:29,代码来源:FileChangeCache_test.go
示例15: TestUnmarshalNaN
func TestUnmarshalNaN(ot *testing.T) {
value := map[string]interface{}{}
err := Unmarshal([]byte("notanum: .NaN"), &value)
kmgTest.Equal(err, nil)
kmgTest.Equal(math.IsNaN(value["notanum"].(float64)), true)
//c.Assert(err, IsNil)
//c.Assert(math.IsNaN(value["notanum"].(float64)), Equals, true)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:8,代码来源:decode_test.go
示例16: TestMustFromMysqlFormatDefaultTZ
func TestMustFromMysqlFormatDefaultTZ(ot *testing.T) {
t := MustFromMysqlFormatDefaultTZ("2001-01-01 00:00:00")
kmgTest.Equal(t.Hour(), 0)
kmgTest.Equal(t.Day(), 1)
t = MustFromMysqlFormatDefaultTZ("0000-00-00 00:00:00")
kmgTest.Equal(t.IsZero(), true)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:8,代码来源:time_test.go
示例17: TestFixLocalTimeToOffsetSpecifiedZoneTime
func TestFixLocalTimeToOffsetSpecifiedZoneTime(ot *testing.T) {
otherZoneTime := FixLocalTimeToOffsetSpecifiedZoneTime(3600, localTime)
kmgTest.Equal(otherZoneTime, "2015-11-12 07:15:55")
otherZoneTime = FixLocalTimeToOffsetSpecifiedZoneTime(7200, localTime)
kmgTest.Equal(otherZoneTime, "2015-11-12 08:15:55")
otherZoneTime = FixLocalTimeToOffsetSpecifiedZoneTime(-18000, localTime)
kmgTest.Equal(otherZoneTime, "2015-11-12 01:15:55")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:8,代码来源:time_test.go
示例18: TestHash
func TestHash(ot *testing.T) {
etag, err := ComputeHashFromFile("testFile/1.txt")
kmgTest.Equal(err, nil)
kmgTest.Equal(etag, "FqmZPjZHBoFquj4lcXhQwmyc0Nid")
etag = ComputeHashFromBytes([]byte("abc"))
kmgTest.Equal(etag, "FqmZPjZHBoFquj4lcXhQwmyc0Nid")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:8,代码来源:Hash_test.go
示例19: BenchmarkFastRandReader
func BenchmarkFastRandReader(ot *testing.B) {
ot.StopTimer()
buf := make([]byte, ot.N)
ot.SetBytes(int64(1))
ot.StartTimer()
n, err := FastRandReader.Read(buf)
kmgTest.Equal(n, ot.N)
kmgTest.Equal(err, nil)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:9,代码来源:FastRandReader_test.go
示例20: TestKmgCipherV2
func TestKmgCipherV2(ot *testing.T) {
//加密数据,可以正确解密测试
for _, origin := range [][]byte{
[]byte(""),
[]byte("1"),
[]byte("12"),
[]byte("123"),
[]byte("1234"),
[]byte("12345"),
[]byte("123456"),
[]byte("1234567"),
[]byte("12345678"),
[]byte("123456789"),
[]byte("1234567890"),
[]byte("123456789012345"),
[]byte("1234567890123456"),
[]byte("12345678901234567"),
} {
ob := EncryptV2([]byte("1"), origin)
ret, err := DecryptV2([]byte("1"), ob)
kmgTest.Equal(err, nil)
kmgTest.Equal(ret, origin)
}
//任意数据传入解密不会挂掉,并且会报错
for _, origin := range [][]byte{
[]byte(""),
[]byte("1"),
[]byte("12"),
[]byte("123"),
[]byte("1234"),
[]byte("12345"),
[]byte("123456"),
[]byte("1234567"),
[]byte("12345678"),
[]byte("123456789"),
[]byte("1234567890"),
[]byte("123456789012345"),
[]byte("1234567890123456"),
[]byte("12345678901234567"),
} {
_, err := Decrypt([]byte("1"), origin)
kmgTest.Ok(err != nil)
}
origin := []byte("1234567890123456712345678901234567")
//多次加密得到不同的结果 (随机化iv)
kmgTest.Ok(!bytes.Equal(EncryptV2([]byte("1"), origin), EncryptV2([]byte("1"), origin)))
//修改任何一个字节都会报错 (hash)
ob := EncryptV2([]byte("1"), origin)
for i := 0; i < len(ob); i++ {
newOb := make([]byte, len(ob))
newOb[i] = -newOb[i]
_, err := DecryptV2([]byte("1"), newOb)
kmgTest.Ok(err != nil)
}
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:56,代码来源:kmgEncryptV2_test.go
注:本文中的github.com/bronze1man/kmg/kmgTest.Equal函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论