forked from msoap/go-carpet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunix_only_test.go
73 lines (65 loc) · 1.96 KB
/
unix_only_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
62
63
64
65
66
67
68
69
70
71
72
73
// +build !windows
package main
import (
"reflect"
"testing"
)
func Test_getCoverForDir(t *testing.T) {
_, _, err := getCoverForDir("./testdata/not_exists.out", []string{}, Config{colors256: false})
if err == nil {
t.Errorf("1. getCoverForDir() error failed")
}
// ---
bytes, _, err := getCoverForDir("./testdata/cover_00.out", []string{}, Config{colors256: false})
if err != nil {
t.Errorf("2. getCoverForDir() failed: %v", err)
}
expect, err := readFile("./testdata/colored_00.txt")
if err != nil {
t.Errorf("3. getCoverForDir() failed: %v", err)
}
if !reflect.DeepEqual(bytes, expect) {
t.Errorf("4. getCoverForDir() not equal")
}
// ---
bytes, _, err = getCoverForDir("./testdata/cover_00.out", []string{}, Config{colors256: true})
if err != nil {
t.Errorf("5. getCoverForDir() failed: %v", err)
}
expect, err = readFile("./testdata/colored_01.txt")
if err != nil {
t.Errorf("6. getCoverForDir() failed: %v", err)
}
if !reflect.DeepEqual(bytes, expect) {
t.Errorf("7. getCoverForDir() not equal")
}
// ---
_, _, err = getCoverForDir("./testdata/cover_01.out", []string{}, Config{colors256: true})
if err == nil {
t.Errorf("8. getCoverForDir() not exists go file")
}
// ---
bytes, _, err = getCoverForDir("./testdata/cover_00.out", []string{"file_01.go"}, Config{colors256: false})
if err != nil {
t.Errorf("9. getCoverForDir() failed: %v", err)
}
expect, err = readFile("./testdata/colored_02.txt")
if err != nil {
t.Errorf("10. getCoverForDir() failed: %v", err)
}
if !reflect.DeepEqual(bytes, expect) {
t.Errorf("11. getCoverForDir() not equal")
}
// ---
bytes, _, err = getCoverForDir("./testdata/cover_02.out", []string{}, Config{colors256: false})
if err != nil {
t.Errorf("12. getCoverForDir() failed: %v", err)
}
expect, err = readFile("./testdata/colored_03.txt")
if err != nil {
t.Errorf("13. getCoverForDir() failed: %v", err)
}
if !reflect.DeepEqual(bytes, expect) {
t.Errorf("14. getCoverForDir() not equal")
}
}