Merge pull request #6595 from LK4D4/env_benchmarks

Benchmarks for engine/env
This commit is contained in:
unclejack 2014-06-24 23:35:00 +03:00
commit 3b2cc0082b

View file

@ -1,10 +1,15 @@
package testutils
import (
"math/rand"
"testing"
"time"
)
const chars = "abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` "
// Timeout calls f and waits for 100ms for it to complete.
// If it doesn't, it causes the tests to fail.
// t must be a valid testing context.
@ -21,3 +26,12 @@ func Timeout(t *testing.T, f func()) {
case <-onDone:
}
}
// RandomString returns random string of specified length
func RandomString(length int) string {
res := make([]byte, length)
for i := 0; i < length; i++ {
res[i] = chars[rand.Intn(len(chars))]
}
return string(res)
}