From 36543c1541a1812c23a860d76ecd6096023fb539 Mon Sep 17 00:00:00 2001 From: LK4D4 Date: Sun, 22 Jun 2014 15:58:43 +0400 Subject: [PATCH] Benchmarks for engine/env Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) --- testutils/testutils.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testutils/testutils.go b/testutils/testutils.go index 4655e58..9c664ff 100644 --- a/testutils/testutils.go +++ b/testutils/testutils.go @@ -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) +}