[cairo-commit] rcairo/test test_paper.rb,1.1,1.2

Kouhei Sutou commit at pdx.freedesktop.org
Tue Apr 8 23:24:23 PDT 2008


Committed by: kou

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

Modified Files:
	test_paper.rb 
Log Message:
* src/lib/cairo/paper.rb, test/test_paper.rb: improve parser.


Index: test_paper.rb
===================================================================
RCS file: /cvs/cairo/rcairo/test/test_paper.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_paper.rb	9 Apr 2008 06:15:42 -0000	1.1
+++ test_paper.rb	9 Apr 2008 06:28:54 -0000	1.2
@@ -1,6 +1,11 @@
 require 'cairo'
 
 class PaperTest < Test::Unit::TestCase
+  def test_parse_paper
+    a4 = Cairo::Paper::A4
+    assert_parse(a4, a4)
+  end
+
   def test_parse_name
     assert_parse(:A4, "A4")
     assert_parse(:A4, "A4")
@@ -23,6 +28,7 @@
     assert_parse(paper(100.5, 200.9), "100.5mmx200.9")
     assert_parse(paper(100.5, 200.9), "100.5mmx200.9")
     assert_parse(paper(25.4, 215.9), "1inchx8.5inch")
+    assert_parse(paper(100, 200), [100, 200])
 
     exception = assert_raise(Cairo::Paper::UnknownUnit) do
       Cairo::Paper.parse("100kmx100")
@@ -30,6 +36,17 @@
     assert_equal("km", exception.unit)
   end
 
+  def test_unrecognized_input
+    assert_nothing_raised do
+      Cairo::Paper.parse({})
+    end
+
+    exception = assert_raise(Cairo::Paper::UnrecognizedPaperDescription) do
+      Cairo::Paper.parse({}, true)
+    end
+    assert_equal({}, exception.description)
+  end
+
   private
   def paper(width, height)
     Cairo::Paper.new(width, height)



More information about the cairo-commit mailing list