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_with_percent
27 assert_geometry 50, 64,
30 "120x112%" => [60, 72]
33 def test_should_resize_with_percent_and_no_width
34 assert_geometry 50, 64,
40 def test_should_resize_with_percent_and_no_height
41 assert_geometry 50, 64,
47 def test_should_resize_with_less
48 assert_geometry 50, 64,
51 "100x100<" => [78, 100],
52 "100x112<" => [88, 112],
56 def test_should_resize_with_less_and_no_width
57 assert_geometry 50, 64,
63 def test_should_resize_with_less_and_no_height
64 assert_geometry 50, 64,
70 def test_should_resize_with_greater
71 assert_geometry 50, 64,
74 "100x100>" => [50, 64],
75 "100x112>" => [50, 64],
79 def test_should_resize_with_greater_and_no_width
80 assert_geometry 50, 64,
86 def test_should_resize_with_greater_and_no_height
87 assert_geometry 50, 64,
94 def assert_geometry(width, height, values)
95 values.each do |geo, result|
96 # run twice to verify the Geometry string isn't modified after a run
97 geo = Geometry.from_s(geo)
98 2.times { assert_equal result, [width, height] / geo }