From f7f8c2814882a0cb5c5f4e192b87a107da2f0a6c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 17 Jan 2019 14:47:46 +0800 Subject: [PATCH] fix bench tests (#47) --- db_test.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/db_test.go b/db_test.go index 5505bc5f..ff14a487 100644 --- a/db_test.go +++ b/db_test.go @@ -233,8 +233,15 @@ func BenchmarkSliceInterfaceQuery(b *testing.B) { b.Error(err) } b.Log(slice) - if *slice[1].(*string) != "xlw" { - b.Error(errors.New("name should be xlw")) + switch slice[1].(type) { + 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 { b.Error(err) } - if m["name"].(string) != "xlw" { - b.Log(m) - b.Error(errors.New("name should be xlw")) + switch m["name"].(type) { + case string: + 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")) + } } }