forked from StevenACoffman/testdemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymflower_test.go
39 lines (37 loc) · 869 Bytes
/
symflower_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
package testdemo
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestIsSorted(t *testing.T) {
type testCase struct {
Name string
Array []int
Expected bool
}
validate := func(t *testing.T, tc testCase) {
t.Helper()
t.Run(tc.Name, func(t *testing.T) {
t.Helper()
t.Log("case:", tc.Name)
actual := IsSorted(tc.Array)
require.Equal(t, tc.Expected, actual)
})
}
validate(t, testCase{Name: "Empty",
Array: []int{},
Expected: true,
})
validate(t, testCase{Name: "Single element",
Array: []int{0},
Expected: true,
})
validate(t, testCase{Name: "Two elements",
Array: []int{0, 1},
Expected: true, // actually true, but we want to see failures
})
validate(t, testCase{Name: "Two elements unsorted",
Array: []int{1, 0},
Expected: false, // actually false, but we want to see failures
})
}