Sha256: 33ce455235d6c1239c9418c4cf1206b257535b36f7b31e919a800c5fb0d49784

Contents?: true

Size: 1.31 KB

Versions: 22

Compression:

Stored size: 1.31 KB

Contents

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

require 'test_helper'
require 'hexapdf/font/invalid_glyph'

describe HexaPDF::Font::InvalidGlyph do
  before do
    font = Object.new
    font.define_singleton_method(:missing_glyph_id) { 0 }
    font.define_singleton_method(:full_name) { "Test Roman" }
    font_wrapper = Object.new
    font_wrapper.define_singleton_method(:wrapped_font) { font }
    @glyph = HexaPDF::Font::InvalidGlyph.new(font_wrapper, "str")
  end

  it "returns the missing glyph id for id/name" do
    assert_equal(0, @glyph.id)
    assert_equal(0, @glyph.name)
  end

  it "returns 0 for all glyph dimensions" do
    assert_equal(0, @glyph.x_min)
    assert_equal(0, @glyph.x_max)
    assert_equal(0, @glyph.y_min)
    assert_equal(0, @glyph.y_max)
  end

  it "doesn't allow the application of word spacing" do
    refute(@glyph.apply_word_spacing?)
  end

  it "returns false when asked whether it is valid" do
    refute(@glyph.valid?)
  end

  it "returns true if the glyph represents a control character" do
    refute(@glyph.control_char?)
    assert(HexaPDF::Font::InvalidGlyph.new(nil, "\n"))
    assert(HexaPDF::Font::InvalidGlyph.new(nil, "\u{8203}"))
  end

  it "can represent itself for debug purposes" do
    assert_equal('#<HexaPDF::Font::InvalidGlyph font="Test Roman" id=0 "str">',
                 @glyph.inspect)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hexapdf-1.2.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-1.1.1 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-1.1.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-1.0.3 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-1.0.2 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-1.0.1 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-1.0.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.47.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.46.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.45.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.44.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.41.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.40.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.39.1 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.39.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.38.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.37.2 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.37.1 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.37.0 test/hexapdf/font/test_invalid_glyph.rb
hexapdf-0.36.0 test/hexapdf/font/test_invalid_glyph.rb