Sha256: ba7d0561101c9aaba7d464ffcea3a2d043a6ad8af72176ab47ef2ba889f08b9d
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 KB
Contents
# encoding: UTF-8 require './test_helper' require 'test/unit' class ScanlineTest < Test::Unit::TestCase def scanline(index = 0) image = lena_image image.scanline(index) end def test_class assert_kind_of(FreeImage::Scanline, scanline) end def test_bytesize assert_equal(lena_image.pitch, scanline.bytesize) end def test_pixelsize assert_equal(lena_image.width, scanline.pixelsize) end def test_color_type assert_equal(FreeImage::RGBTriple, scanline.send(:color_type)) end def test_color_size assert_equal(3, scanline.send(:color_type).size) end def test_color expected = lena_image.pixel_color(0, 0) actual = scanline[0] assert_equal(expected[:red], actual[:red]) assert_equal(expected[:green], actual[:green]) assert_equal(expected[:blue], actual[:blue]) assert_equal(expected[:reserved], 0) end def test_invalid_y error = assert_raise(RangeError) do lena_image.scanline(-1) end assert_equal("Index must be between 0 and 511", error.to_s) error = assert_raise(RangeError) do lena_image.scanline(1000) end assert_equal("Index must be between 0 and 511", error.to_s) end def test_invalid_x error = assert_raise(RangeError) do scanline[-1] end assert_equal("Index must be between 0 and 511", error.to_s) error = assert_raise(RangeError) do scanline[1000] end assert_equal("Index must be between 0 and 511", error.to_s) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
free-image-0.6.2 | test/test_scanline.rb |
free-image-0.6.1 | test/test_scanline.rb |
free-image-0.6.0 | test/test_scanline.rb |
free-image-0.5.0 | test/test_scanline.rb |