Sha256: e62970e5a7991a7692d41f870acf7d64764e2cc655be87a26941eda6c0e44ba9

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class TestImageSize < Test::Unit::TestCase

  def setup
    @dir = File.dirname(__FILE__)
    @data = [
      ['4_1_2.gif',       :gif,  668, 481],
      ['2-4-7.png',       :png,  640, 532],
      ['tokyo_tower.jpg', :jpeg, 320, 240],
      ['bmp.bmp',         :bmp,   50,  50],
      ['pgm.pgm',         :pgm,   90,  55],
      ['pbm.pbm',         :pbm,   85,  55],
      ['cursor.xbm',      :xbm,   16,  16],
      ['tiff.tiff',       :tiff,  64,  64],
      ['test.xpm',        :xpm,   32,  32],
      ['tower_e.psd',     :psd,   20,  20],
      ['pcx.pcx',         :pcx,   70,  60],
      ['detect.swf',      :swf,  450, 200],
      ['test_helper.rb',  nil,   nil, nil],
    ]
  end

  def teardown
  end

  def test_string
    @data.each do |file_name, format, widht, height|
      open(File.join(@dir, file_name), 'rb') do |fh|
        img_data = fh.read

        img = ImageSize.new(img_data)
        assert_equal(format, img.format)
        assert_equal(widht,  img.width)
        assert_equal(height, img.height)
      end
    end
  end

  def test_io
    @data.each do |file_name, format, widht, height|
      open(File.join(@dir, file_name), 'rb') do |fh|
        img = ImageSize.new(fh)
        assert_equal(format, img.format)
        assert_equal(widht,  img.width)
        assert_equal(height, img.height)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
image_size-1.0.4 test/test_image_size.rb
image_size-1.0.3 test/test_image_size.rb
image_size-1.0.2 test/test_image_size.rb
image_size-1.0.1 test/test_image_size.rb
image_size-1.0.0 test/test_image_size.rb