require 'spec_helper' describe 'PNG testsuite' do # context 'Decoding broken images' do # png_suite_files(:broken).each do |fname| # it "should report #{File.basename(fname)} as broken" do # lambda { SugarPNG::Image.from_file(fname) }.should raise_error(SugarPNG::Exception) # end # # it "should not report #{File.basename(fname)} as unsupported" do # lambda { SugarPNG::Image.from_file(fname) }.should_not raise_error(SugarPNG::NotSupported) # end # end # end context 'Decoding supported images' do png_suite_files(:basic, '*.png').each do |fname| reference = rgba_for(fname) if fname =~ /[in](\d)[apgc](\d\d)\.png$/ color_mode, bit_depth = $1.to_i, $2.to_i else next end it "decodes #{File.basename(fname)} (color mode: #{color_mode}, bit depth: #{bit_depth}) exactly the same as the reference image" do decoded = SugarPNG::Canvas.from_file(fname) File.open(reference, 'rb') do |f| if decoded.to_rgba_stream != f.read File.open(reference+".my", 'wb') { |fo| fo<