forked from gdelugre/origami
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_object_tree.rb
33 lines (27 loc) · 949 Bytes
/
test_object_tree.rb
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
require 'minitest/autorun'
require 'stringio'
class TestPDFObjectTree < Minitest::Test
def setup
@pdf = PDF.new.append_page
@contents = ContentStream.new("abc")
@pdf.pages.first.Contents = @contents
@pdf.Catalog.Loop = @pdf.Catalog
@pdf.save StringIO.new
end
def test_pdf_object_tree
assert_instance_of Catalog, @pdf.Catalog
assert_nil @pdf.Catalog.parent
@pdf.each_object(recursive: true) do |obj|
assert_kind_of Origami::Object, obj
assert_equal obj.document, @pdf
unless obj.indirect?
assert_kind_of Origami::Object, obj.parent
assert_equal obj.parent.document, @pdf
end
end
enum = @pdf.each_object(recursive: true)
assert_kind_of Enumerator, enum
assert enum.include?(@pdf.Catalog.Pages)
assert enum.include?(@contents.dictionary)
end
end