Skip to content
Newer
Older
100644 64 lines (49 sloc) 1.5 KB
95590df Add initial tests for Draw class
rmagick authored
1
2 #! /usr/local/bin/ruby -w
3
4 require 'RMagick'
5 require 'test/unit'
6 require 'test/unit/ui/console/testrunner'
7
68fe654 Test @@_dummy_img_
rmagick authored
8 class Magick::Draw
9 def self._dummy_img_
10 @@_dummy_img_
11 end
12 end
13
95590df Add initial tests for Draw class
rmagick authored
14 class Draw_UT < Test::Unit::TestCase
15
16 def setup
17 @draw = Magick::Draw.new
18 end
19
68fe654 Test @@_dummy_img_
rmagick authored
20 # Ensure @@_dummy_img_ class var is working properly
21 def test_dummy_img
22 # initially this variable is not defined.
23 assert_raise(NameError) do
24 Magick::Draw._dummy_img_
25 end
26
27 # cause it to become defined. save the object id.
28 @draw.get_type_metrics("ABCDEF")
29 dummy = nil
30 assert_nothing_raised do
31 dummy = Magick::Draw._dummy_img_
32 end
33
34 assert_instance_of(Magick::Image, dummy)
35
36 # ensure that it is always the same object
37 @draw.get_type_metrics("ABCDEF")
38 dummy2 = nil
39 assert_nothing_raised do
40 dummy2 = Magick::Draw._dummy_img_
41 end
42 assert_same(dummy, dummy2)
43 end
44
95590df Add initial tests for Draw class
rmagick authored
45 def test_patterns
46 img = Magick::Image.new(20,20)
47 assert_nothing_raised { @draw.fill_pattern = img }
48 assert_nothing_raised { @draw.stroke_pattern = img }
49
50 ilist = Magick::ImageList.new
51 ilist << img
52 assert_nothing_raised { @draw.fill_pattern = ilist }
53 assert_nothing_raised { @draw.stroke_pattern = ilist }
54
55 assert_raise(NoMethodError) { @draw.fill_pattern = 1 }
56 assert_raise(NoMethodError) { @draw.stroke_pattern = 1 }
57 end
58 end
59
60 if __FILE__ == $0
61 Test::Unit::UI::Console::TestRunner.run(Draw_UT)
62 end
63
Something went wrong with that request. Please try again.