Sha256: beda0353bc3f2eca377639d42a57940649645c00e7f211e1135ade4fb0825000

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/xref_section'

describe HexaPDF::XRefSection do
  before do
    @xref_section = HexaPDF::XRefSection.new
  end

  describe "each_subsection" do
    def assert_subsections(result)
      assert_equal(result, @xref_section.each_subsection.map {|s| s.map(&:oid)})
    end

    it "works for newly initialized objects" do
      assert_subsections([[]])
    end

    it "works for a single subsection" do
      @xref_section.add_in_use_entry(1, 0, 0)
      @xref_section.add_in_use_entry(2, 0, 0)
      assert_subsections([[1, 2]])
    end

    it "works for multiple subsections" do
      @xref_section.add_in_use_entry(10, 0, 0)
      @xref_section.add_in_use_entry(11, 0, 0)
      @xref_section.add_in_use_entry(1, 0, 0)
      @xref_section.add_in_use_entry(2, 0, 0)
      @xref_section.add_in_use_entry(20, 0, 0)
      assert_subsections([[1, 2], [10, 11], [20]])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hexapdf-0.2.0 test/hexapdf/test_xref_section.rb
hexapdf-0.1.0 test/hexapdf/test_xref_section.rb