Test Failed
Push — master ( afbf8e...641184 )
by Valentin
02:35
created

util/rand/rand_test.go   A

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B rand.TestRand 0 16 6
1
package rand
2
3
import (
4
	"regexp"
5
	"testing"
6
)
7
8
func TestRand(t *testing.T) {
9
	set := []int{10, 100}
10
	var reg = &regexp.Regexp{}
11
	reg = regexp.MustCompile("^[a-zA-Z0-9]*$")
12
	for i, n := range set {
13
		str := Strings(n)
14
		if len(str) != n || !reg.MatchString(str) {
15
			t.Errorf("random string incorrect for %d:\ngot `%s` of length `%d`\nexpected a-zA-A0-9 regex of `%d` length", i, str, len(str), n)
16
		}
17
	}
18
19
	str1 := Strings(10)
20
	str2 := Strings(10)
21
22
	if str1 == str2 {
23
		t.Errorf("random strings should not repeat:\ngot `%s` `%s`", str1, str2)
24
	}
25
}
26