[cairo-commit] rcairo/test test_paper.rb,1.3,1.4

Kouhei Sutou commit at pdx.freedesktop.org
Thu Apr 10 21:41:22 PDT 2008


Committed by: kou

Update of /cvs/cairo/rcairo/test
In directory kemper:/tmp/cvs-serv29559/test

Modified Files:
	test_paper.rb 
Log Message:
* src/lib/cairo/papers.rb: add landscape papers.
* test/test_paper.rb, src/lib/cairo/paper.rb: support name parsing.
* src/lib/cairo/paper.rb: improve unit handling.


Index: test_paper.rb
===================================================================
RCS file: /cvs/cairo/rcairo/test/test_paper.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test_paper.rb	11 Apr 2008 02:39:12 -0000	1.3
+++ test_paper.rb	11 Apr 2008 04:46:08 -0000	1.4
@@ -8,7 +8,7 @@
 
   def test_parse_name
     assert_parse(:A4, "A4")
-    assert_parse(:A4, "A4")
+    assert_parse(:A4_LANDSCAPE, "A4 landscape")
     assert_parse(:A4, :A4)
     assert_parse(:A4, :a4)
 
@@ -36,6 +36,11 @@
     assert_equal("km", exception.unit)
   end
 
+  def test_parse_size_with_name
+    assert_parse(paper(28.346456664, 24094.488168, nil, "Name"),
+                 "1cmx8.5m#Name")
+  end
+
   def test_unrecognized_input
     assert_nothing_raised do
       Cairo::Paper.parse({})
@@ -60,8 +65,8 @@
   end
 
   private
-  def paper(width, height)
-    Cairo::Paper.new(width, height)
+  def paper(width, height, *rest)
+    Cairo::Paper.new(width, height, *rest)
   end
 
   def parse(paper_description)
@@ -71,23 +76,6 @@
   def assert_parse(expected, paper_description, message=nil)
     expected = Cairo::Paper.const_get(expected) if expected.is_a?(Symbol)
     actual_paper = parse(paper_description)
-    assert_equal_paper(expected, actual_paper, message)
-  end
-
-  def assert_equal_paper(expected, actual, message=nil)
-    delta = 0.01
-    assert_block(build_message(message,
-                               "<?> expected but was\n<?>.",
-                               expected, actual)) do
-      if actual.nil?
-        expected.nil?
-      else
-        (expected.width - delta < actual.width and
-         actual.width < expected.width + delta) and
-          (expected.height - delta < actual.height and
-           actual.height < expected.height + delta) and
-          expected.name == actual.name
-      end
-    end
+    assert_equal(expected, actual_paper, message)
   end
 end



More information about the cairo-commit mailing list