OSDN Git Service

add package
[bytom/vapor.git] / vendor / github.com / hashicorp / yamux / util_test.go
1 package yamux
2
3 import (
4         "testing"
5 )
6
7 func TestAsyncSendErr(t *testing.T) {
8         ch := make(chan error)
9         asyncSendErr(ch, ErrTimeout)
10         select {
11         case <-ch:
12                 t.Fatalf("should not get")
13         default:
14         }
15
16         ch = make(chan error, 1)
17         asyncSendErr(ch, ErrTimeout)
18         select {
19         case <-ch:
20         default:
21                 t.Fatalf("should get")
22         }
23 }
24
25 func TestAsyncNotify(t *testing.T) {
26         ch := make(chan struct{})
27         asyncNotify(ch)
28         select {
29         case <-ch:
30                 t.Fatalf("should not get")
31         default:
32         }
33
34         ch = make(chan struct{}, 1)
35         asyncNotify(ch)
36         select {
37         case <-ch:
38         default:
39                 t.Fatalf("should get")
40         }
41 }
42
43 func TestMin(t *testing.T) {
44         if min(1, 2) != 1 {
45                 t.Fatalf("bad")
46         }
47         if min(2, 1) != 1 {
48                 t.Fatalf("bad")
49         }
50 }