Changeset 2298


Ignore:
Timestamp:
Apr 19, 2008, 1:48:32 PM (12 years ago)
Author:
Pascal Terjan
Message:

Fix args type checks in Caca::Display.new

Location:
libcaca/trunk/ruby
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/ruby/caca-display.c

    r2296 r2298  
    5454    }
    5555
    56     if(CLASS_OF(arg1) == T_STRING)
     56    if(TYPE(arg1) == T_STRING)
    5757    {
    5858        driver = StringValuePtr(arg1);
    59         if(CLASS_OF(arg2) == T_STRING)
     59        if(TYPE(arg2) == T_STRING)
    6060        {
    6161            rb_raise(rb_eArgError, "Only one argument can be a string");
    6262        }
    6363    }
    64     else if(CLASS_OF(arg2) == T_STRING)
     64    else if(TYPE(arg2) == T_STRING)
    6565    {
    6666        driver = StringValuePtr(arg2);
  • libcaca/trunk/ruby/t/tc_display.rb

    r2297 r2298  
    44class TC_Canvas < Test::Unit::TestCase
    55    def test_create
    6         d = Caca::Display.new
     6        d = Caca::Display.new
    77        assert_not_nil(d, 'Display creation failed')
    88    end
    99    def test_create_with_driver
    10         d = Caca::Display.new(nil, Caca::Display.driver_list[0])
     10        d = Caca::Display.new(Caca::Display.driver_list[0])
    1111        assert_not_nil(d, 'Display creation failed')
     12    end
     13    def test_create_wrong_args
     14        assert_raise(RuntimeError){Caca::Display.new("plop")}
     15        driver = Caca::Display.driver_list[0]
     16        assert_raise(ArgumentError){Caca::Display.new(driver, driver)}
     17        c = Cucul::Canvas.new(3, 3)
     18        assert_raise(ArgumentError){Caca::Display.new(c, c)}
    1219    end
    1320    def test_create_from_canvas
    1421        c = Cucul::Canvas.new(3, 3)
    15         d = Caca::Display.new(c)
     22        d = Caca::Display.new(c)
    1623        assert_not_nil(d, 'Display creation failed')
    17         assert_equal(d.canvas, c, 'Wrong canvas')
     24        assert_equal(d.canvas, c, 'Wrong canvas')
    1825    end
    1926    def test_set_title
Note: See TracChangeset for help on using the changeset viewer.