File: test_objects.rb

package info (click to toggle)
origami-pdf 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,484 kB
  • sloc: ruby: 17,883; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (3)
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 TestPDFObjects < 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