-
Notifications
You must be signed in to change notification settings - Fork 5
/
alphabet_test.go
54 lines (47 loc) · 879 Bytes
/
alphabet_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
47
48
49
50
51
52
53
54
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestValidateAlphabet(t *testing.T) {
t.Parallel()
tests := []struct {
desc string
give string
wantErr string
}{
{
desc: "empty",
wantErr: "must have at least two items",
},
{
desc: "single",
give: "a",
wantErr: "must have at least two items",
},
{
desc: "good",
give: "0123456789",
},
{
desc: "dupes",
give: "asdffghhjjkl",
wantErr: "alphabet has duplicates: ['f' 'h' 'j']",
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.desc, func(t *testing.T) {
t.Parallel()
var alpha alphabet
err := alpha.Set(tt.give)
if len(tt.wantErr) == 0 {
assert.NoError(t, err)
return
}
require.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
})
}
}