| @@ -1,12 +1,12 @@ | |||||
| require 'caca' | require 'caca' | ||||
| class TC_Canvas < Test::Unit::TestCase | |||||
| class TC_Canvas < MiniTest::Test | |||||
| def setup | def setup | ||||
| @c = Caca::Canvas.new(3, 3) | @c = Caca::Canvas.new(3, 3) | ||||
| end | end | ||||
| def test_create | def test_create | ||||
| c = Caca::Canvas.new(3, 3) | c = Caca::Canvas.new(3, 3) | ||||
| assert_not_nil(c, 'Canvas creation failed') | |||||
| refute_nil(c, 'Canvas creation failed') | |||||
| assert(c.width == 3 && c.height == 3, 'Wrong size for new canvas') | assert(c.width == 3 && c.height == 3, 'Wrong size for new canvas') | ||||
| end | end | ||||
| def test_width | def test_width | ||||
| @@ -47,13 +47,13 @@ class TC_Canvas < Test::Unit::TestCase | |||||
| end | end | ||||
| def test_render | def test_render | ||||
| c = Caca::Canvas.new(4,4) | c = Caca::Canvas.new(4,4) | ||||
| c.put_str(0,0,"plop") | |||||
| f = Caca::Font.new(Caca::Font.list[0]) | |||||
| assert_not_nil(c.render(f, c.width*f.width, c.height*f.height, c.width*f.width*4)) | |||||
| c.put_str(0,0,"plop") | |||||
| f = Caca::Font.new(Caca::Font.list[0]) | |||||
| refute_nil(c.render(f, c.width*f.width, c.height*f.height, c.width*f.width*4)) | |||||
| end | end | ||||
| def test_fail_render | def test_fail_render | ||||
| c = Caca::Canvas.new(4,4) | c = Caca::Canvas.new(4,4) | ||||
| assert_raise(ArgumentError) { | |||||
| assert_raises(ArgumentError) { | |||||
| c.render(nil, c.width, c.height, c.width*4) | c.render(nil, c.width, c.height, c.width*4) | ||||
| } | } | ||||
| end | end | ||||
| @@ -1,25 +1,25 @@ | |||||
| require 'caca' | require 'caca' | ||||
| class TC_Canvas < Test::Unit::TestCase | |||||
| class TC_Canvas < MiniTest::Test | |||||
| def test_create | def test_create | ||||
| d = Caca::Display.new() | d = Caca::Display.new() | ||||
| assert_not_nil(d, 'Display creation failed') | |||||
| refute_nil(d, 'Display creation failed') | |||||
| end | end | ||||
| def test_create_with_driver | def test_create_with_driver | ||||
| d = Caca::Display.new(Caca::Display.driver_list[0]) | d = Caca::Display.new(Caca::Display.driver_list[0]) | ||||
| assert_not_nil(d, 'Display creation failed') | |||||
| refute_nil(d, 'Display creation failed') | |||||
| end | end | ||||
| def test_create_wrong_args | def test_create_wrong_args | ||||
| c = Caca::Canvas.new(3, 3) | c = Caca::Canvas.new(3, 3) | ||||
| assert_raise(RuntimeError){Caca::Display.new("plop")} | |||||
| assert_raise(RuntimeError){Caca::Display.new(c, "plop")} | |||||
| assert_raise(ArgumentError){Caca::Display.new("plop", "plop")} | |||||
| assert_raise(ArgumentError){Caca::Display.new(c, c)} | |||||
| assert_raises(RuntimeError){Caca::Display.new("plop")} | |||||
| assert_raises(RuntimeError){Caca::Display.new(c, "plop")} | |||||
| assert_raises(ArgumentError){Caca::Display.new("plop", "plop")} | |||||
| assert_raises(ArgumentError){Caca::Display.new(c, c)} | |||||
| end | end | ||||
| def test_create_from_canvas | def test_create_from_canvas | ||||
| c = Caca::Canvas.new(3, 3) | c = Caca::Canvas.new(3, 3) | ||||
| d = Caca::Display.new(c) | d = Caca::Display.new(c) | ||||
| assert_not_nil(d, 'Display creation failed') | |||||
| refute_nil(d, 'Display creation failed') | |||||
| assert_equal(d.canvas, c, 'Wrong canvas') | assert_equal(d.canvas, c, 'Wrong canvas') | ||||
| end | end | ||||
| def test_set_title | def test_set_title | ||||
| @@ -1,50 +1,41 @@ | |||||
| require 'caca' | require 'caca' | ||||
| class TC_Canvas < Test::Unit::TestCase | |||||
| class TC_Canvas < MiniTest::Test | |||||
| def test_create | def test_create | ||||
| assert_nothing_raised { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| } | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| end | end | ||||
| def test_fail_create | def test_fail_create | ||||
| assert_raise(RuntimeError) { | |||||
| assert_raises(RuntimeError) { | |||||
| d = Caca::Dither.new(-1, 32, 32, 32, 0, 0, 0, 0) | d = Caca::Dither.new(-1, 32, 32, 32, 0, 0, 0, 0) | ||||
| } | |||||
| } | |||||
| end | end | ||||
| def test_set_palette | def test_set_palette | ||||
| assert_nothing_raised { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.palette=[[0xfff, 0xfff, 0xfff, 0xfff]]*256 | |||||
| } | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.palette = [[0xfff, 0xfff, 0xfff, 0xfff]] * 256 | |||||
| end | end | ||||
| def test_fail_set_palette | def test_fail_set_palette | ||||
| assert_raise(ArgumentError) { | |||||
| assert_raises(ArgumentError) { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | ||||
| d.palette=[] | |||||
| } | |||||
| d.palette = [] | |||||
| } | |||||
| end | end | ||||
| def test_fail_set_palette2 | def test_fail_set_palette2 | ||||
| assert_raise(RuntimeError) { | |||||
| assert_raises(RuntimeError) { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | ||||
| d.palette=[[0xffff, 0, 0, 0]]*256 | |||||
| } | |||||
| d.palette = [[0xffff, 0, 0, 0]] * 256 | |||||
| } | |||||
| end | end | ||||
| def test_set_brightness | def test_set_brightness | ||||
| assert_nothing_raised { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.brightness=0.5 | |||||
| } | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.brightness = 0.5 | |||||
| end | end | ||||
| def test_set_gamma | def test_set_gamma | ||||
| assert_nothing_raised { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.gamma=0.5 | |||||
| } | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.gamma = 0.5 | |||||
| end | end | ||||
| def test_set_contrast | def test_set_contrast | ||||
| assert_nothing_raised { | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.contrast=0.5 | |||||
| } | |||||
| d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||||
| d.contrast = 0.5 | |||||
| end | end | ||||
| end | end | ||||
| @@ -1,21 +1,21 @@ | |||||
| require 'caca' | require 'caca' | ||||
| class TC_Canvas < Test::Unit::TestCase | |||||
| class TC_Canvas < MiniTest::Test | |||||
| def test_list | def test_list | ||||
| assert_not_nil(Caca::Font.list) | |||||
| refute_nil(Caca::Font.list) | |||||
| end | end | ||||
| def test_load | def test_load | ||||
| Caca::Font.list.each{|f| | |||||
| font = Caca::Font.new(f) | |||||
| assert_not_nil(font) | |||||
| assert_not_nil(font.width) | |||||
| assert_not_nil(font.height) | |||||
| assert_not_nil(font.blocks) | |||||
| } | |||||
| Caca::Font.list.each{|f| | |||||
| font = Caca::Font.new(f) | |||||
| refute_nil(font) | |||||
| refute_nil(font.width) | |||||
| refute_nil(font.height) | |||||
| refute_nil(font.blocks) | |||||
| } | |||||
| end | end | ||||
| def test_fail_load | def test_fail_load | ||||
| assert_raise(RuntimeError) { | |||||
| Caca::Font.new("This font should not exist") | |||||
| } | |||||
| assert_raises(RuntimeError) { | |||||
| Caca::Font.new("This font should not exist") | |||||
| } | |||||
| end | end | ||||
| end | end | ||||
| @@ -1,19 +1,19 @@ | |||||
| require 'caca' | require 'caca' | ||||
| class TC_Frame < Test::Unit::TestCase | |||||
| def setup | |||||
| @c = Caca::Canvas.new(3, 3) | |||||
| end | |||||
| def test_create | |||||
| f = @c.create_frame(1) | |||||
| assert(f, 'Frame creation failed') | |||||
| @c.free_frame(1) | |||||
| end | |||||
| def test_name | |||||
| f = @c.create_frame(1) | |||||
| assert(@c.frame_name, 'Failed to get frame name') | |||||
| @c.frame_name="test" | |||||
| assert(@c.frame_name == "test", 'Failed to set frame name') | |||||
| @c.free_frame(1) | |||||
| end | |||||
| class TC_Frame < MiniTest::Test | |||||
| def setup | |||||
| @c = Caca::Canvas.new(3, 3) | |||||
| end | |||||
| def test_create | |||||
| f = @c.create_frame(1) | |||||
| assert(f, 'Frame creation failed') | |||||
| @c.free_frame(1) | |||||
| end | |||||
| def test_name | |||||
| f = @c.create_frame(1) | |||||
| assert(@c.frame_name, 'Failed to get frame name') | |||||
| @c.frame_name="test" | |||||
| assert(@c.frame_name == "test", 'Failed to set frame name') | |||||
| @c.free_frame(1) | |||||
| end | |||||
| end | end | ||||
| @@ -1,11 +1,10 @@ | |||||
| #!/usr/bin/ruby | #!/usr/bin/ruby | ||||
| require 'test/unit' | |||||
| require 'minitest/autorun' | |||||
| $LOAD_PATH.unshift(".libs").unshift("lib") | $LOAD_PATH.unshift(".libs").unshift("lib") | ||||
| Dir.glob("t/tc*.rb").each{ |t| | |||||
| Dir.glob("./t/tc*.rb").each{ |t| | |||||
| require t | require t | ||||
| } | } | ||||
| exit Test::Unit::AutoRunner.run | |||||