Permalink
Browse files

adding decoder test

  • Loading branch information...
1 parent 46e1639 commit c90052067fc5836ef26d736832441effc28345f6 @tenderlove committed Sep 28, 2008
Showing with 35 additions and 0 deletions.
  1. BIN test/assets/icha.mp3
  2. +15 −0 test/helper.rb
  3. +20 −0 test/mpeg/test_decoder.rb
View
BIN test/assets/icha.mp3
Binary file not shown.
View
15 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
View
20 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.