| Conditions | 6 |
| Total Lines | 16 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package rand |
||
| 8 | func TestRand(t *testing.T) { |
||
| 9 | set := []int{10, 100} |
||
| 10 | var reg = ®exp.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 | } |
||
| 26 |