-
Notifications
You must be signed in to change notification settings - Fork 6
/
msoleps_test.go
67 lines (60 loc) · 1.53 KB
/
msoleps_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
package msoleps
import (
"os"
"sync"
"testing"
)
var (
testDocSum = "test/DocumentSummaryInformation"
testSum = "test/SummaryInformation"
testSum1 = "test/SummaryInformation1"
)
func testFile(t *testing.T, path string) *Reader {
file, _ := os.Open(path)
defer file.Close()
doc, err := NewFrom(file)
if err != nil {
t.Errorf("Error opening file; Returns error: %v", err)
}
return doc
}
func TestReader_concurrency(t *testing.T) {
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
_ = testFile(t, testDocSum)
}()
go func() {
defer wg.Done()
_ = testFile(t, testDocSum)
}()
wg.Wait()
}
func TestDocSum(t *testing.T) {
doc := testFile(t, testDocSum)
if len(doc.Property) != 12 {
t.Errorf("Expecting 12 properties, got %d", len(doc.Property))
}
if doc.Property[1].String() != "Australian Broadcasting Corporation" {
t.Errorf("Expecting 'ABC' as second property, got %s", doc.Property[1])
}
}
func TestSum(t *testing.T) {
doc := testFile(t, testSum)
if len(doc.Property) != 17 {
t.Errorf("Expecting 17 properties, got %d", len(doc.Property))
}
if doc.Property[5].String() != "Normal" {
t.Errorf("Expecting 'Normal' as sixth property, got %s", doc.Property[5])
}
}
func TestSum1(t *testing.T) {
doc := testFile(t, testSum1)
if len(doc.Property) != 3 {
t.Errorf("Expecting 3 properties, got %d", len(doc.Property))
}
if doc.Property[0].String() != "Mail" {
t.Errorf("Expecting 'Mail' as first property, got %s", doc.Property[0])
}
}