Skip to content

Instantly share code, notes, and snippets.

@lacolaco
Last active August 29, 2015 14:05
Show Gist options
  • Save lacolaco/aef7b701d66f21e2a87d to your computer and use it in GitHub Desktop.
Save lacolaco/aef7b701d66f21e2a87d to your computer and use it in GitHub Desktop.
bbop in golangのテストコード
package la0c
import (
"strings"
"testing"
)
func TestCalcMatchCount(t *testing.T) {
noMatch := "レ,ド,ッ,ビ,ビ,ッ,レ,・,レ,ビ,ビ,ー,ド,ン"
if CalcMatchCount(strings.Split(noMatch, ",")) != 0 {
t.Errorf("it's no match")
}
if CalcMatchCount(strings.Split(ANSWER, ",")) != 9 {
t.Errorf("it's perfect match")
}
}
func BenchmarkTryNoSeed(b *testing.B) {
for i := 0; i < b.N; i++ {
TryBBOP("")
}
}
func BenchmarkTryLongSeed(b *testing.B) {
for i := 0; i < b.N; i++ {
TryBBOP("Foooooooooooooooooooooooooooooooooooooooooo")
}
}
BenchmarkTryNoSeed 500000 4096 ns/op
BenchmarkTryLongSeed 500000 4844 ns/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment