-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings_test.go
More file actions
34 lines (27 loc) · 757 Bytes
/
strings_test.go
File metadata and controls
34 lines (27 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"testing"
)
// assertRandomStringLength ensures that the generated string matches the
// desired length.
func assertRandomStringLength(t *testing.T, ask int, want int) {
got := len(RandomString(ask))
if got != want {
t.Errorf("len(RandomString(%v)) = %v; want %v", ask, got, want)
}
}
func TestRandomStringLengthNegativeOne(t *testing.T) {
assertRandomStringLength(t, -1, 0)
}
func TestRandomStringLengthZero(t *testing.T) {
assertRandomStringLength(t, 0, 0)
}
func TestRandomStringLengthOne(t *testing.T) {
assertRandomStringLength(t, 1, 1)
}
func TestRandomStringLengthTen(t *testing.T) {
assertRandomStringLength(t, 10, 10)
}
func TestRandomStringLengthTwenty(t *testing.T) {
assertRandomStringLength(t, 20, 20)
}