-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_test.go
46 lines (43 loc) · 901 Bytes
/
account_test.go
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
35
36
37
38
39
40
41
42
43
44
45
46
package is
import "testing"
// TestNickname tests the Nickname function.
func TestNickname(t *testing.T) {
tests := []struct {
name string
nickname string
want bool
}{
{
name: "Valid Nickname - Alphanumeric",
nickname: "User123",
want: true,
},
{
name: "Valid Nickname - Underscores",
nickname: "User_123",
want: true,
},
{
name: "Invalid Nickname - Special Characters",
nickname: "User!123",
want: false,
},
{
name: "Invalid Nickname - Too Long",
nickname: "ThisUsernameIsWayTooLong1234567890",
want: false,
},
{
name: "Invalid Nickname - Empty String",
nickname: "",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Nickname(tt.nickname); got != tt.want {
t.Errorf("Nickname() = %v, want %v", got, tt.want)
}
})
}
}