Sha256: c8b28bad962f16cc46c2e8bb7e325a5f762d67376e245514e9fd005efe1dcab2

Contents?: true

Size: 1.38 KB

Versions: 61

Compression:

Stored size: 1.38 KB

Contents

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

require_relative 'common'
require 'hexapdf/filter/flate_decode'

describe HexaPDF::Filter::FlateDecode do
  include CommonFilterTests

  before do
    @obj = HexaPDF::Filter::FlateDecode
    @all_test_cases = [["abcdefg".force_encoding(Encoding::BINARY),
                        "x\xDAKLJNIMK\a\x00\n\xDB\x02\xBD".force_encoding(Encoding::BINARY)]]
    @decoded = @all_test_cases[0][0]
    @encoded = @all_test_cases[0][1]
    @encoded_predictor = "x\xDAcJdbD@\x00\x05\x8F\x00v".force_encoding(Encoding::BINARY)
    @predictor_opts = {Predictor: 12}
  end

  describe "decoder" do
    it "works for empty input" do
      assert_equal('', collector(@obj.decoder(Fiber.new { "" })))
      assert_equal('', collector(@obj.decoder(Fiber.new {})))
    end

    it "applies the Predictor after decoding" do
      assert_equal(@decoded, collector(@obj.decoder(feeder(@encoded_predictor), @predictor_opts)))
    end

    it "fails on invalid input" do
      assert_raises(HexaPDF::FilterError) do
        collector(@obj.decoder(feeder(@encoded[0..-2], @encoded.length - 3)))
      end
      assert_raises(HexaPDF::FilterError) do
        collector(@obj.decoder(feeder("some data")))
      end
    end
  end

  describe "encoder" do
    it "applies the Predictor before encoding" do
      assert_equal(@encoded_predictor, collector(@obj.encoder(feeder(@decoded), @predictor_opts)))
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
hexapdf-0.30.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.29.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.28.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.27.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.26.2 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.26.1 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.26.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.25.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.24.2 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.24.1 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.24.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.23.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.22.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.21.1 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.21.0 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.20.4 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.20.3 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.20.2 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.20.1 test/hexapdf/filter/test_flate_decode.rb
hexapdf-0.20.0 test/hexapdf/filter/test_flate_decode.rb