2 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/geometry')) unless Object.const_defined?(:Geometry)
4 class GeometryTest < Test::Unit::TestCase
6 assert_geometry 50, 64,
12 def test_should_resize_no_width
13 assert_geometry 50, 64,
19 def test_should_resize_no_height
20 assert_geometry 50, 64,
26 def test_should_resize_no_height_with_x
27 assert_geometry 50, 64,
33 def test_should_resize_with_percent
34 assert_geometry 50, 64,
37 "120x112%" => [60, 72]
40 def test_should_resize_with_percent_and_no_width
41 assert_geometry 50, 64,
47 def test_should_resize_with_percent_and_no_height
48 assert_geometry 50, 64,
54 def test_should_resize_with_less
55 assert_geometry 50, 64,
58 "100x100<" => [78, 100],
59 "100x112<" => [88, 112],
63 def test_should_resize_with_less_and_no_width
64 assert_geometry 50, 64,
70 def test_should_resize_with_less_and_no_height
71 assert_geometry 50, 64,
77 def test_should_resize_with_greater
78 assert_geometry 50, 64,
81 "100x100>" => [50, 64],
82 "100x112>" => [50, 64],
86 def test_should_resize_with_greater_and_no_width
87 assert_geometry 50, 64,
93 def test_should_resize_with_greater_and_no_height
94 assert_geometry 50, 64,
101 def assert_geometry(width, height, values)
102 values.each do |geo, result|
103 # run twice to verify the Geometry string isn't modified after a run
104 geo = Geometry.from_s(geo)
105 2.times { assert_equal result, [width, height] / geo }