-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrndgroups_test.go
More file actions
48 lines (37 loc) · 907 Bytes
/
rndgroups_test.go
File metadata and controls
48 lines (37 loc) · 907 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"testing"
)
func Test_shuffle(t *testing.T) {
srcData := []string{"e", "c", "b", "d", "f", "a"}
data := []string{"a", "b", "c", "d", "e", "f"}
shuffle(data, 0)
if !equal(srcData, data) {
t.Errorf("Shuffled slice is not shuffled")
}
}
func Test_convertByteSliceToList(t *testing.T) {
srcData := []byte("a\nb\nc\nd")
response := convertByteSliceToList(srcData)
if len(response) != 4 {
t.Errorf("Expected 4 elements, got %d", len(response))
}
}
func Test_printGroups(t *testing.T) {
// No checks here, just print the groups
data := []string{"a", "b", "c", "d", "e", "f", "g"}
printGroups(data, 4)
}
// Equal tells whether a and b contain the same elements.
// A nil argument is equivalent to an empty slice.
func equal(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}