Permalink
Browse files

add some tests for various unsupported image files

  • Loading branch information...
1 parent a13f6e3 commit 51734fc12ac8bd4187e9bac57075f323d46f68da @yob yob committed Apr 24, 2009
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Binary file not shown.
View
@@ -83,8 +83,6 @@ def image(file, options={})
when :png then
info = Prawn::Images::PNG.new(image_content)
build_png_object(image_content, info)
- else
- raise Errors::UnsupportedImageType, "image file is an unrecognised format"
end
image_registry[image_sha1] = {:obj => image_obj, :info => info}
end
@@ -324,7 +322,7 @@ def detect_image_format(content)
elsif top[0, 8] == "\x89PNG\x0d\x0a\x1a\x0a"
return :png
else
- raise ArgumentError, "Unsupported Image Type"
+ raise Errors::UnsupportedImageType, "image file is an unrecognised format"
end
end
View
@@ -35,6 +35,21 @@
info.height.should == 453
end
+
+ it "should raise an UnsupportedImageType if passed a BMP" do
+ filename = "#{Prawn::BASEDIR}/data/images/tru256.bmp"
+ lambda { @pdf.image filename, :at => [100,100] }.should.raise(Prawn::Errors::UnsupportedImageType)
+ end
+
+ it "should raise an UnsupportedImageType if passed an interlaced PNG" do
+ filename = "#{Prawn::BASEDIR}/data/images/dice_interlaced.png"
+ lambda { @pdf.image filename, :at => [100,100] }.should.raise(Prawn::Errors::UnsupportedImageType)
+ end
+
+ it "should raise an UnsupportedImageType if passed a 16 bit PNG" do
+ filename = "#{Prawn::BASEDIR}/data/images/16bit.png"
+ lambda { @pdf.image filename, :at => [100,100] }.should.raise(Prawn::Errors::UnsupportedImageType)
+ end
describe ":fit option" do
it "should fit inside the defined constraints" do

0 comments on commit 51734fc

Please sign in to comment.