-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchan_test.go
51 lines (43 loc) · 923 Bytes
/
chan_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
package assert_test
import (
"testing"
. "github.com/pierrre/assert"
"github.com/pierrre/assert/asserttest"
)
func TestChanEmpty(t *testing.T) {
c := make(chan int)
ok := ChanEmpty(t, c)
True(t, ok)
}
func TestChanEmptyFail(t *testing.T) {
c := make(chan int, 10)
c <- 1
report := asserttest.NewReportAuto(t)
ok := ChanEmpty(t, c, Report(report))
False(t, ok)
}
func TestChanNotEmpty(t *testing.T) {
c := make(chan int, 10)
c <- 1
ok := ChanNotEmpty(t, c)
True(t, ok)
}
func TestChanNotEmptyFail(t *testing.T) {
c := make(chan int)
report := asserttest.NewReportAuto(t)
ok := ChanNotEmpty(t, c, Report(report))
False(t, ok)
}
func TestChanLen(t *testing.T) {
c := make(chan int, 10)
c <- 1
ok := ChanLen(t, c, 1)
True(t, ok)
}
func TestChanLenFail(t *testing.T) {
c := make(chan int, 10)
c <- 1
report := asserttest.NewReportAuto(t)
ok := ChanLen(t, c, 2, Report(report))
False(t, ok)
}