about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_rg_integration.rb2
-rw-r--r--test/test_source_av.rb18
-rw-r--r--test/test_source_sox.rb20
3 files changed, 20 insertions, 20 deletions
diff --git a/test/test_rg_integration.rb b/test/test_rg_integration.rb
index 79a6563..3b78e07 100644
--- a/test/test_rg_integration.rb
+++ b/test/test_rg_integration.rb
@@ -41,7 +41,7 @@ class TestRgIntegration < Minitest::Unit::TestCase
       end while cur["current_offset"] == 0 && sleep(0.01)
     end
 
-    assert_nil cur["current"]["env"]["RGFX"]
+    assert_empty cur["current"]["env"]["RGFX"]
 
     assert_equal DTAS::Format.new.rate * len, cur["current_expect"]
 
diff --git a/test/test_source_av.rb b/test/test_source_av.rb
index 4dba559..78015b3 100644
--- a/test/test_source_av.rb
+++ b/test/test_source_av.rb
@@ -33,7 +33,7 @@ class TestSourceAv < Minitest::Unit::TestCase
 
     x(%W(metaflac --set-tag=FOO=BAR #{tmp.path}))
     x(%W(metaflac --add-replay-gain #{tmp.path}))
-    source = DTAS::Source::Av.new(tmp.path)
+    source = DTAS::Source::Av.new.try(tmp.path)
     assert_equal source.comments["FOO"], "BAR", source.inspect
     rg = source.replaygain
     assert_kind_of DTAS::ReplayGain, rg
@@ -60,7 +60,7 @@ class TestSourceAv < Minitest::Unit::TestCase
       end
     end
 
-    source = DTAS::Source::Av.new(a.path)
+    source = DTAS::Source::Av.new.try(a.path)
     rg = source.replaygain
     assert_kind_of DTAS::ReplayGain, rg
     assert_in_delta 0.0, rg.track_peak.to_f, 0.00000001
@@ -71,31 +71,31 @@ class TestSourceAv < Minitest::Unit::TestCase
 
   def test_offset
     tmp = new_file('flac') or return
-    source = DTAS::Source::Av.new(*%W(#{tmp.path} 5s))
+    source = DTAS::Source::Av.new.try(*%W(#{tmp.path} 5s))
     assert_equal 5, source.offset_samples
 
-    source = DTAS::Source::Av.new(*%W(#{tmp.path} 1:00:00.5))
+    source = DTAS::Source::Av.new.try(*%W(#{tmp.path} 1:00:00.5))
     expect = 1 * 60 * 60 * 44100 + (44100/2)
     assert_equal expect, source.offset_samples
 
-    source = DTAS::Source::Av.new(*%W(#{tmp.path} 1:10.5))
+    source = DTAS::Source::Av.new.try(*%W(#{tmp.path} 1:10.5))
     expect = 1 * 60 * 44100 + (10 * 44100) + (44100/2)
     assert_equal expect, source.offset_samples
 
-    source = DTAS::Source::Av.new(*%W(#{tmp.path} 10.03))
+    source = DTAS::Source::Av.new.try(*%W(#{tmp.path} 10.03))
     expect = (10 * 44100) + (44100 * 3/100.0)
     assert_equal expect, source.offset_samples
   end
 
   def test_offset_us
     tmp = new_file('flac') or return
-    source = DTAS::Source::Av.new(*%W(#{tmp.path} 441s))
+    source = DTAS::Source::Av.new.try(*%W(#{tmp.path} 441s))
     assert_equal 10000.0, source.offset_us
 
-    source = DTAS::Source::Av.new(*%W(#{tmp.path} 22050s))
+    source = DTAS::Source::Av.new.try(*%W(#{tmp.path} 22050s))
     assert_equal 500000.0, source.offset_us
 
-    source = DTAS::Source::Av.new(tmp.path, '1')
+    source = DTAS::Source::Av.new.try(tmp.path, '1')
     assert_equal 1000000.0, source.offset_us
   end
 end
diff --git a/test/test_source_sox.rb b/test/test_source_sox.rb
index f2e0699..4dec808 100644
--- a/test/test_source_sox.rb
+++ b/test/test_source_sox.rb
@@ -31,7 +31,7 @@ class TestSource < Minitest::Unit::TestCase
     return if `which metaflac`.strip.size == 0
     tmp = new_file('flac') or return
 
-    source = DTAS::Source::Sox.new(tmp.path)
+    source = DTAS::Source::Sox.new.try(tmp.path)
     x(%W(metaflac --set-tag=FOO=BAR #{tmp.path}))
     x(%W(metaflac --add-replay-gain #{tmp.path}))
     assert_equal source.comments["FOO"], "BAR"
@@ -48,7 +48,7 @@ class TestSource < Minitest::Unit::TestCase
     a = new_file('mp3') or return
     b = new_file('mp3') or return
 
-    source = DTAS::Source::Sox.new(a.path)
+    source = DTAS::Source::Sox.new.try(a.path)
 
     # redirect stdout to /dev/null temporarily, mp3gain is noisy
     File.open("/dev/null", "w") do |null|
@@ -72,31 +72,31 @@ class TestSource < Minitest::Unit::TestCase
 
   def test_offset
     tmp = new_file('sox') or return
-    source = DTAS::Source::Sox.new(*%W(#{tmp.path} 5s))
+    source = DTAS::Source::Sox.new.try(*%W(#{tmp.path} 5s))
     assert_equal 5, source.offset_samples
 
-    source = DTAS::Source::Sox.new(*%W(#{tmp.path} 1:00:00.5))
+    source = DTAS::Source::Sox.new.try(*%W(#{tmp.path} 1:00:00.5))
     expect = 1 * 60 * 60 * 44100 + (44100/2)
     assert_equal expect, source.offset_samples
 
-    source = DTAS::Source::Sox.new(*%W(#{tmp.path} 1:10.5))
+    source = DTAS::Source::Sox.new.try(*%W(#{tmp.path} 1:10.5))
     expect = 1 * 60 * 44100 + (10 * 44100) + (44100/2)
     assert_equal expect, source.offset_samples
 
-    source = DTAS::Source::Sox.new(*%W(#{tmp.path} 10.03))
+    source = DTAS::Source::Sox.new.try(*%W(#{tmp.path} 10.03))
     expect = (10 * 44100) + (44100 * 3/100.0)
     assert_equal expect, source.offset_samples
   end
 
   def test_offset_us
     tmp = new_file('sox') or return
-    source = DTAS::Source::Sox.new(*%W(#{tmp.path} 441s))
+    source = DTAS::Source::Sox.new.try(*%W(#{tmp.path} 441s))
     assert_equal 10000.0, source.offset_us
 
-    source = DTAS::Source::Sox.new(*%W(#{tmp.path} 22050s))
+    source = DTAS::Source::Sox.new.try(*%W(#{tmp.path} 22050s))
     assert_equal 500000.0, source.offset_us
 
-    source = DTAS::Source::Sox.new(tmp.path, '1')
+    source = DTAS::Source::Sox.new.try(tmp.path, '1')
     assert_equal 1000000.0, source.offset_us
   end
 
@@ -106,7 +106,7 @@ class TestSource < Minitest::Unit::TestCase
       cmd = %W(sox -r 96000 -b 24 -c 2 -n #{tmp.path} trim 0 1)
       system(*cmd)
       assert $?.success?, "#{cmd.inspect} failed: #$?"
-      fmt = DTAS::Source::Sox.new(tmp.path).format
+      fmt = DTAS::Source::Sox.new.try(tmp.path).format
       assert_equal 96000, fmt.rate
       assert_equal 2, fmt.channels
       tmp.unlink