Sha256: ce100aa732d742cebff4ac0c7a8fe988dbf54f3cf66a7765e044f158c1fd54ab

Contents?: true

Size: 1.76 KB

Versions: 12

Compression:

Stored size: 1.76 KB

Contents

require 'test_helper'

# Font class unit test class.
class FontTest < Test::Unit::TestCase
   def test_01
      fonts = []
      fonts.push(Font.new(Font::MODERN, "Courier New"))
      fonts.push(Font.new(Font::ROMAN, "Arial"))
      fonts.push(Font.new(Font::SWISS, "Tahoma"))
      fonts.push(Font.new(Font::NIL, "La La La"))

      assert(fonts[0] == fonts[0])
      assert(!(fonts[0] == fonts[1]))
      assert(!(fonts[1] == 'a string of text'))
      assert(fonts[2] == Font.new(Font::SWISS, "Tahoma"))

      assert(fonts[0].family == Font::MODERN)
      assert(fonts[1].family == Font::ROMAN)
      assert(fonts[2].family == Font::SWISS)
      assert(fonts[3].family == Font::NIL)

      assert(fonts[0].name == 'Courier New')
      assert(fonts[1].name == 'Arial')
      assert(fonts[2].name == 'Tahoma')
      assert(fonts[3].name == 'La La La')

      assert(fonts[0].to_s == 'Family: modern, Name: Courier New')
      assert(fonts[1].to_s(3) == '   Family: roman, Name: Arial')
      assert(fonts[2].to_s(6) == '      Family: swiss, Name: Tahoma')
      assert(fonts[3].to_s(-1) == 'Family: nil, Name: La La La')

      assert(fonts[0].to_rtf == '\fmodern Courier New;')
      assert(fonts[1].to_rtf(2) == '  \froman Arial;')
      assert(fonts[2].to_rtf(4) == '    \fswiss Tahoma;')
      assert(fonts[3].to_rtf(-6) == '\fnil La La La;')

      begin
         Font.new(12345, "Ningy")
         flunk("Created a Font object with an invalid family setting.")
      rescue RTFError
      rescue Test::Unit::AssertionFailedError => error
         raise error
      rescue => error
         flunk("Unexpected exception caught checking font creation with "\
               "an invalid family. Exception type #{error.class.name}.")
      end
   end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
thechrisoshow-ruby-rtf-0.2.0 test/font_test.rb
rtf-0.3.3 test/font_test.rb
rtf-0.3.2 test/font_test.rb
rtf-0.3.0 test/font_test.rb
panmind-rtf-0.4.1 test/font_test.rb
panmind-rtf-0.4.0 test/font_test.rb
clbustos-rtf-0.3.1 test/font_test.rb
panmind-rtf-0.3.1 test/font_test.rb
clbustos-rtf-0.3.0 test/font_test.rb
clbustos-rtf-0.2.2 test/font_test.rb
clbustos-rtf-0.2.1 test/font_test.rb
clbustos-rtf-0.1.2 test/font_test.rb