forked from myzhan/boomer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
task_test.go
61 lines (51 loc) · 1.17 KB
/
task_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
55
56
57
58
59
60
61
package boomer
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestSort(t *testing.T) {
Convey("test Sort no change", t, func() {
var (
t1 = &Task{Order: 1, Name: "t1"}
t2 = &Task{Order: 2, Name: "t2"}
t3 = &Task{Order: 3, Name: "t3"}
)
expTs := []*Task{t1, t2, t3}
ts := []*Task{t1, t2, t3}
Sort(ts)
So(ts, ShouldResemble, expTs)
})
Convey("test Sort reverse", t, func() {
var (
t1 = &Task{Order: 1, Name: "t1"}
t2 = &Task{Order: 2, Name: "t2"}
t3 = &Task{Order: 3, Name: "t3"}
)
expTs := []*Task{t1, t2, t3}
ts := []*Task{t3, t2, t1}
Sort(ts)
So(ts, ShouldResemble, expTs)
})
Convey("test Sort change", t, func() {
var (
t1 = &Task{Order: 1, Name: "t1"}
t2 = &Task{Order: 2, Name: "t2"}
t3 = &Task{Order: 3, Name: "t3"}
)
expTs := []*Task{t1, t2, t3}
ts := []*Task{t2, t3, t1}
Sort(ts)
So(ts, ShouldResemble, expTs)
})
Convey("test Sort minus", t, func() {
var (
t1 = &Task{Order: -1, Name: "t1"}
t2 = &Task{Order: 2, Name: "t2"}
t3 = &Task{Order: 3, Name: "t3"}
)
expTs := []*Task{t1, t2, t3}
ts := []*Task{t2, t3, t1}
Sort(ts)
So(ts, ShouldResemble, expTs)
})
}