Title: [924] trunk/image_voodoo: Adding image science test
- Revision
- 924
- Author
- nicksieger
- Date
- 2008-03-04 16:41:00 -0500 (Tue, 04 Mar 2008)
Log Message
Adding image science test
Modified Paths
Added Paths
Diff
Modified: trunk/image_voodoo/Manifest.txt (923 => 924)
--- trunk/image_voodoo/Manifest.txt 2008-03-04 14:44:36 UTC (rev 923)
+++ trunk/image_voodoo/Manifest.txt 2008-03-04 21:41:00 UTC (rev 924)
@@ -2,4 +2,7 @@
Rakefile
README.txt
LICENSE.txt
+lib/image_science.rb
lib/image_voodoo.rb
+test/pix.png
+test/test_image_science.rb
Modified: trunk/image_voodoo/Rakefile (923 => 924)
--- trunk/image_voodoo/Rakefile 2008-03-04 14:44:36 UTC (rev 923)
+++ trunk/image_voodoo/Rakefile 2008-03-04 21:41:00 UTC (rev 924)
@@ -1,4 +1,4 @@
-MANIFEST = FileList["Manifest.txt", "Rakefile", "README.txt", "LICENSE.txt", "lib/**/*"]
+MANIFEST = FileList["Manifest.txt", "Rakefile", "README.txt", "LICENSE.txt", "lib/**/*", "test/**/*"]
file "Manifest.txt" => :manifest
task :manifest do
Added: trunk/image_voodoo/lib/image_science.rb (0 => 924)
--- trunk/image_voodoo/lib/image_science.rb (rev 0)
+++ trunk/image_voodoo/lib/image_science.rb 2008-03-04 21:41:00 UTC (rev 924)
@@ -0,0 +1,2 @@
+require 'image_voodoo'
+ImageScience = ImageVoodoo
\ No newline at end of file
Added: trunk/image_voodoo/test/pix.png
(Binary files differ)
Property changes on: trunk/image_voodoo/test/pix.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/image_voodoo/test/test_image_science.rb (0 => 924)
--- trunk/image_voodoo/test/test_image_science.rb (rev 0)
+++ trunk/image_voodoo/test/test_image_science.rb 2008-03-04 21:41:00 UTC (rev 924)
@@ -0,0 +1,124 @@
+require 'test/unit/testcase'
+require 'test/unit' if $0 == __FILE__
+require 'image_science'
+
+class TestImageScience < Test::Unit::TestCase
+ def deny x; assert ! x; end
+
+ def setup
+ @path = 'test/pix.png'
+ @tmppath = 'test/pix-tmp.png'
+ @h = @w = 50
+ end
+
+ def teardown
+ File.unlink @tmppath if File.exist? @tmppath
+ end
+
+ def test_class_with_image
+ ImageScience.with_image @path do |img|
+ assert_kind_of ImageScience, img
+ assert_equal @h, img.height
+ assert_equal @w, img.width
+ assert img.save(@tmppath)
+ end
+
+ assert File.exists?(@tmppath)
+
+ ImageScience.with_image @tmppath do |img|
+ assert_kind_of ImageScience, img
+ assert_equal @h, img.height
+ assert_equal @w, img.width
+ end
+ end
+
+ def test_class_with_image_missing
+ assert_raises TypeError do
+ ImageScience.with_image @path + "nope" do |img|
+ flunk
+ end
+ end
+ end
+
+ def test_class_with_image_missing_with_img_extension
+ assert_nil ImageScience.with_image("[EMAIL PROTECTED]") do |img|
+ flunk
+ end
+ end
+
+ def test_resize
+ ImageScience.with_image @path do |img|
+ img.resize(25, 25) do |thumb|
+ assert thumb.save(@tmppath)
+ end
+ end
+
+ assert File.exists?(@tmppath)
+
+ ImageScience.with_image @tmppath do |img|
+ assert_kind_of ImageScience, img
+ assert_equal 25, img.height
+ assert_equal 25, img.width
+ end
+ end
+
+ def test_resize_floats
+ ImageScience.with_image @path do |img|
+ img.resize(25.2, 25.7) do |thumb|
+ assert thumb.save(@tmppath)
+ end
+ end
+
+ assert File.exists?(@tmppath)
+
+ ImageScience.with_image @tmppath do |img|
+ assert_kind_of ImageScience, img
+ assert_equal 25, img.height
+ assert_equal 25, img.width
+ end
+ end
+
+ def test_resize_zero
+ assert_raises ArgumentError do
+ ImageScience.with_image @path do |img|
+ img.resize(0, 25) do |thumb|
+ assert thumb.save(@tmppath)
+ end
+ end
+ end
+
+ deny File.exists?(@tmppath)
+
+ assert_raises ArgumentError do
+ ImageScience.with_image @path do |img|
+ img.resize(25, 0) do |thumb|
+ assert thumb.save(@tmppath)
+ end
+ end
+ end
+
+ deny File.exists?(@tmppath)
+ end
+
+ def test_resize_negative
+ assert_raises ArgumentError do
+ ImageScience.with_image @path do |img|
+ img.resize(-25, 25) do |thumb|
+ assert thumb.save(@tmppath)
+ end
+ end
+ end
+
+ deny File.exists?(@tmppath)
+
+ assert_raises ArgumentError do
+ ImageScience.with_image @path do |img|
+ img.resize(25, -25) do |thumb|
+ assert thumb.save(@tmppath)
+ end
+ end
+ end
+
+ deny File.exists?(@tmppath)
+ end
+end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel