-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodel_test.go
92 lines (85 loc) · 1.66 KB
/
model_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package model
import (
"bytes"
"os"
"reflect"
"testing"
)
func TestEmptyDocument(t *testing.T) {
var d Document
var b bytes.Buffer
err := d.Write(&b, nil)
if err != nil {
t.Fatal(err)
}
if len(b.Bytes()) != 285 {
t.Fatalf("expected 285 bytes for an empty Document, got %d", len(b.Bytes()))
}
}
func TestCloneEncrypt(t *testing.T) {
e := Encrypt{
CF: map[Name]CrypFilter{
"lmds": {},
"sdsd": {
Recipients: []string{"ds5"},
},
},
}
e2 := e.Clone()
if !reflect.DeepEqual(e, e2) {
t.Errorf("expected %v, got %v", e, e2)
}
}
func TestCloneNames(t *testing.T) {
e := NameDictionary{
EmbeddedFiles: EmbeddedFileTree{
{Name: "ùmlld", FileSpec: &FileSpec{}},
},
Dests: DestTree{
Kids: []DestTree{
{
Names: []NameToDest{
{Name: "mùdlsld", Destination: DestinationExplicitIntern{}},
},
},
},
Names: []NameToDest{
{},
},
},
}
cache := newCloneCache()
e2 := e.clone(cache)
if !reflect.DeepEqual(e, e2) {
t.Errorf("expected %v, got %v", e, e2)
}
}
func TestCloneDocument(t *testing.T) {
var doc Document
if clone := doc.Clone(); !reflect.DeepEqual(doc, clone) {
t.Errorf("expected %v, got %v", doc, clone)
}
}
func TestOpenAction(t *testing.T) {
var d Document
p3 := &PageObject{}
d.Catalog.Pages.Kids = []PageNode{
&PageObject{},
&PageObject{},
p3,
&PageTree{
Kids: []PageNode{&PageObject{}},
},
}
d.Catalog.OpenAction = Action{ActionType: ActionGoTo{D: DestinationExplicitIntern{
Page: p3, Location: DestinationLocationFit("Fit"),
}}}
f, err := os.Create("test/open_action.pdf")
if err != nil {
t.Fatal(err)
}
err = d.Write(f, nil)
if err != nil {
t.Fatal(err)
}
}