Skip to content

Commit

Permalink
adding decoder test
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Sep 28, 2008
1 parent 46e1639 commit c900520
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Binary file added test/assets/icha.mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions test/helper.rb
@@ -0,0 +1,15 @@
require 'md5'
require 'test/unit'
require 'icanhasaudio'
require 'tempfile'

%w(../lib ../ext).each do |path|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path)))
end

module ICANHASAUDIO
class TestCase < Test::Unit::TestCase
MP3_FILE = File.dirname(__FILE__) + "/assets/icha.mp3"
undef :default_test
end
end
20 changes: 20 additions & 0 deletions test/mpeg/test_decoder.rb
@@ -0,0 +1,20 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helper'))

module Audio
module MPEG
class TestDecoder < ICANHASAUDIO::TestCase
def setup
@decoder = MPEG::Decoder.new
end

def test_decode
out = "#{Dir::tmpdir}/out.wav"
File.open(out, 'wb+') { |outfile|
@decoder.decode(File.open(MP3_FILE, 'rb'), outfile)
}
digest = Digest::MD5.hexdigest(File.read(out))
assert_equal '9a55bcdda77ec7c20f32031632927403', digest
end
end
end
end

0 comments on commit c900520

Please sign in to comment.