[cairo-commit] rcairo/test test_font_options.rb,NONE,1.1

Kouhei Sutou commit at pdx.freedesktop.org
Wed Aug 13 05:27:42 PDT 2008


Committed by: kou

Update of /cvs/cairo/rcairo/test
In directory kemper:/tmp/cvs-serv5200/test

Added Files:
	test_font_options.rb 
Log Message:
        * src/lib/cairo/constants.rb (Cairo::LCD_FILTER_*): define.

        * src/rb_cairo.h (RVAL2CRLCDFILTER,
        rb_cairo_lcd_filter_from_ruby_object): add.

        * src/cairo.def (rb_cairo_lcd_filter_from_ruby_object): add.

        * src/rb_cairo_font_options.c (Cairo::FontOptions#lcd_filter,
        Cairo::FontOptions#lcd_filter=): add.

        * test/test_font_options.rb: add.


--- NEW FILE: test_font_options.rb ---
require 'cairo'

class FontOptionsTest < Test::Unit::TestCase
  include CairoTestUtils

  def setup
    @options = Cairo::FontOptions.new
  end

  def test_lcd_filter
    only_cairo_version(1, 7, 2)

    assert_equal(Cairo::LCDFilter::DEFAULT, @options.lcd_filter)
    @options.lcd_filter = :fir3
    assert_equal(Cairo::LCDFilter::FIR3, @options.lcd_filter)

    assert_invalid_lcd_filter(Cairo::LCDFilter::DEFAULT - 1)
    assert_invalid_lcd_filter(Cairo::LCDFilter::FIR5 + 1)
  end

  def assert_invalid_lcd_filter(value)
    options = Cairo::FontOptions.new
    exception = assert_raise(ArgumentError) do
      options.lcd_filter = value
    end
    min = Cairo::LCDFilter::DEFAULT
    max = Cairo::LCDFilter::FIR5
    assert_equal("invalid lcd_filter: #{value} " +
                 "(expect #{min} <= lcd_filter <= #{max})",
                 exception.message)
  end
end



More information about the cairo-commit mailing list