-
Notifications
You must be signed in to change notification settings - Fork 2
/
list_test.go
57 lines (45 loc) · 1.05 KB
/
list_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
package async_test
import (
"github.com/Southern/async"
"testing"
)
func TestAdd(t *testing.T) {
Status("Creating list")
list := async.New()
Status("Adding routine")
list.Add(func(done async.Done, args ...interface{}) {
Status("Args: %+v", args)
})
if list.Len() > 0 {
Status("Added routine to list")
}
}
func TestMultiple(t *testing.T) {
Status("Creating list")
list := async.New()
Status("Adding multiple routines")
list, _ = list.Multiple(func(done async.Done, args ...interface{}) {
Status("Args: %+v", args)
}, func(done async.Done, args ...interface{}) {
Status("Args2: %+v", args)
})
if list.Len() == 2 {
Status("Added multiple routines to list")
}
}
func TestRemove(t *testing.T) {
Status("Creating list")
list := async.New()
Status("Adding routine")
list, elem := list.Add(func(done async.Done, args ...interface{}) {
Status("Args: %+v", args)
})
if list.Len() > 0 {
Status("Added routine to list")
}
Status("Removing element")
list.Remove(elem)
if list.Len() == 0 {
Status("Removed element from list")
}
}