fix bench tests (#47)

This commit is contained in:
Lunny Xiao 2019-01-17 14:47:46 +08:00 committed by GitHub
parent f50e09f2ad
commit f7f8c28148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 5 deletions

View File

@ -233,8 +233,15 @@ func BenchmarkSliceInterfaceQuery(b *testing.B) {
b.Error(err) b.Error(err)
} }
b.Log(slice) b.Log(slice)
if *slice[1].(*string) != "xlw" { switch slice[1].(type) {
b.Error(errors.New("name should be xlw")) case *string:
if *slice[1].(*string) != "xlw" {
b.Error(errors.New("name should be xlw"))
}
case []byte:
if string(slice[1].([]byte)) != "xlw" {
b.Error(errors.New("name should be xlw"))
}
} }
} }
@ -380,9 +387,17 @@ func BenchmarkMapInterfaceQuery(b *testing.B) {
if err != nil { if err != nil {
b.Error(err) b.Error(err)
} }
if m["name"].(string) != "xlw" { switch m["name"].(type) {
b.Log(m) case string:
b.Error(errors.New("name should be xlw")) if m["name"].(string) != "xlw" {
b.Log(m)
b.Error(errors.New("name should be xlw"))
}
case []byte:
if string(m["name"].([]byte)) != "xlw" {
b.Log(m)
b.Error(errors.New("name should be xlw"))
}
} }
} }