Sha256: 4ea500123bafe9e222d11a0cf89967ee78c8f4205d33211a9e05da85bebc9429

Contents?: true

Size: 942 Bytes

Versions: 4

Compression:

Stored size: 942 Bytes

Contents

require_relative 'helper'


class TestFont < Test::Unit::TestCase

  R = Rays

  def font(*args)
    R::Font.new(*args)
  end

  def test_name()
    assert_kind_of String, font.name
  end

  def test_size()
    assert_kind_of Numeric, font.size

    f = font('Arial', 10)
    assert_equal 10, f.size

    name   = f.name
    f.size = 11
    assert_equal 11,   f.size
    assert_equal name, f.name

    f11    = f.dup
    f.size = 12
    assert_equal 12, f  .size
    assert_equal 11, f11.size
  end

  def test_width()
    assert_equal 0, font.width('')
    w = font.width 'X'
    assert_equal w * 2, font.width('XX')
    assert_equal w * 2, font.width("XX\nX")
    assert_equal w * 2, font.width("XX\nXX")
    assert_equal w * 3, font.width("XX\nXXX")
  end

  def test_height()
    f = font
    assert_equal f.height, f.ascent + f.descent + f.leading
  end

  def test_families()
    assert_not R::Font.families.empty?
  end

end# TestFont

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rays-0.3 test/test_font.rb
rays-0.2.1 test/test_font.rb
rays-0.2 test/test_font.rb
rays-0.1.49 test/test_font.rb