-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoofv_test.go
More file actions
66 lines (61 loc) · 1.43 KB
/
goofv_test.go
File metadata and controls
66 lines (61 loc) · 1.43 KB
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
package goofv
import (
"path"
"runtime"
"strings"
"testing"
)
var (
excelGood = "testfiles/test.good.xls"
excelBad = "testfiles/test.corrupt.xls"
wordGood = "testfiles/test.good.doc"
wordBad = "testfiles/test.corrupt.doc"
pptGood = "testfiles/test.good.ppt"
pptBad = "testfiles/test.corrupt.ppt"
)
func init() {
_, me, _, _ := runtime.Caller(1)
baseFolder := path.Dir(me)
excelGood = strings.Replace(path.Join(baseFolder, excelGood), "/", "\\", -1)
excelBad = strings.Replace(path.Join(baseFolder, excelBad), "/", "\\", -1)
wordGood = strings.Replace(path.Join(baseFolder, wordGood), "/", "\\", -1)
wordBad = strings.Replace(path.Join(baseFolder, wordBad), "/", "\\", -1)
pptGood = strings.Replace(path.Join(baseFolder, pptGood), "/", "\\", -1)
pptBad = strings.Replace(path.Join(baseFolder, pptBad), "/", "\\", -1)
}
func TestExcelGood(t *testing.T) {
result := IsValidExcelFile(excelGood)
if !result {
t.Fail()
}
}
func TestExcelBad(t *testing.T) {
result := IsValidExcelFile(excelBad)
if result {
t.Fail()
}
}
func TestWordGood(t *testing.T) {
result := IsValidWordFile(wordGood)
if !result {
t.Fail()
}
}
func TestWordBad(t *testing.T) {
result := IsValidWordFile(wordBad)
if result {
t.Fail()
}
}
func TestPPTGood(t *testing.T) {
result := IsValidPowerPointFile(pptGood)
if !result {
t.Fail()
}
}
func TestPPTBad(t *testing.T) {
result := IsValidPowerPointFile(pptBad)
if result {
t.Fail()
}
}