53 Star 126 Fork 0

vz/gse

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
token_test.go 871 Bytes
一键复制 编辑 原始数据 按行查看 历史
vz 提交于 2020-06-20 07:01 . Refactor test code
package gse
import (
"fmt"
"testing"
"github.com/vcaesar/tt"
)
var token = Token{
text: []Text{
[]byte("one"),
[]byte("two"),
},
}
func TestTokenEquals(t *testing.T) {
tt.True(t, token.Equals("onetwo"))
}
func TestTokenNotEquals(t *testing.T) {
tt.False(t, token.Equals("one-two"))
}
var strs = []Text{
Text("one"),
Text("two"),
Text("three"),
Text("four"),
}
func TextSliceToString(b *testing.B) {
for i := 0; i < b.N; i++ {
textSliceToString(strs)
}
}
func TextToString(b *testing.B) {
for i := 0; i < b.N; i++ {
textToString(strs)
}
}
func TestBenchmark(t *testing.T) {
fmt.Println("textToString: ")
fmt.Println(testing.Benchmark(TextToString))
fmt.Println("textSliceToString: ")
fmt.Println(testing.Benchmark(TextSliceToString))
}
func BenchmarkEquals(t *testing.B) {
fn := func() {
token.Equals("onetwo")
}
tt.BM(t, fn)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/veni0/gse.git
git@gitee.com:veni0/gse.git
veni0
gse
gse
master

搜索帮助

Cb406eda 1850385 E526c682 1850385