-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions_test.go
More file actions
49 lines (45 loc) · 811 Bytes
/
options_test.go
File metadata and controls
49 lines (45 loc) · 811 Bytes
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
package deadlock
import (
"bufio"
"os"
"testing"
)
func TestOptions_Write_LogBufIsNil(t *testing.T) {
opts := Options{}
if n, err := opts.Write([]byte("foo")); err == nil {
if n != 0 {
t.Fail()
}
} else {
t.Error(err)
}
if err := opts.Flush(); err != nil {
t.Error(err)
}
}
func TestOptions_Write_LogBufIsBufio(t *testing.T) {
var fooText = []byte("foo")
opts := Options{
LogBuf: bufio.NewWriter(os.Stderr),
}
if n, err := opts.Write([]byte("foo")); err == nil {
if n != len(fooText) {
t.Fail()
}
} else {
t.Error(err)
}
if err := opts.Flush(); err != nil {
t.Error(err)
}
}
func TestOptions_PanicsOnMissingCallback(t *testing.T) {
defer func() {
if recover() == nil {
t.Fail()
}
}()
opts := Options{}
opts.PotentialDeadlock() // should panic
t.Fail()
}