Sha256: baafc7957db8492cb65d20ae8705ddd21a260a19c5604795be1716acc469e624

Contents?: true

Size: 1.18 KB

Versions: 21

Compression:

Stored size: 1.18 KB

Contents

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

require_relative 'common'
require 'hexapdf/filter/ascii_hex_decode'

describe HexaPDF::Filter::ASCIIHexDecode do
  include CommonFilterTests

  before do
    @obj = HexaPDF::Filter::ASCIIHexDecode
    @all_test_cases = [['Nov shmoz ka pop.', '4e6f762073686d6f7a206b6120706f702e>']]
    @decoded = @all_test_cases[0][0]
    @encoded = @all_test_cases[0][1]
  end

  describe "decoder" do
    it "ignores whitespace in the input" do
      with_whitespace = @encoded.scan(/./).map {|a| "#{a} \r\t" }.join("\n")
      assert_equal(@decoded, collector(@obj.decoder(feeder(with_whitespace, 1))))
    end

    it "works without the EOD marker" do
      assert_equal(@decoded, collector(@obj.decoder(feeder(@encoded.chop, 5))))
    end

    it "ignores data after the EOD marker" do
      assert_equal(@decoded, collector(@obj.decoder(feeder(@encoded + '4e6f7gzz'))))
    end

    it "assumes the missing char is '0' if the input length is odd" do
      assert_equal(@decoded.chop << ' ', collector(@obj.decoder(feeder(@encoded.chop.chop))))
    end

    it "fails on invalid characters" do
      assert_raises(HexaPDF::FilterError) { @obj.decoder(feeder('f0f0z')).resume }
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hexapdf-0.12.3 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.12.2 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.12.1 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.12.0 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.9 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.8 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.7 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.6 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.5 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.4 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.3 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.2 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.1 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.11.0 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.10.0 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.9.3 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.9.2 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.9.1 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.9.0 test/hexapdf/filter/test_ascii_hex_decode.rb
hexapdf-0.8.0 test/hexapdf/filter/test_ascii_hex_decode.rb