Permalink
Browse files

Test FFMPEG::FIFO

  • Loading branch information...
1 parent b36b878 commit 406bd3fc4140dfc13aadd34f73129784345c2317 @drbrain committed Sep 6, 2009
Showing with 77 additions and 1 deletion.
  1. +1 −1 lib/ffmpeg/fifo.rb
  2. +76 −0 test/test_ffmpeg_fifo.rb
View
@@ -137,7 +137,7 @@ def initialize(bytes)
end
def inspect
- '#<%s:0x%x size %d>' % [self.class, object_id, size]
+ '#<%s:0x%x size %d space %d>' % [self.class, object_id, size, space]
end
end
View
@@ -0,0 +1,76 @@
+require 'ffmpeg/test_case'
+
+class TestFFMPEGFifo < FFMPEG::TestCase
+
+ def setup
+ super
+
+ @fifo = FFMPEG::FIFO.new 20
+ @buffer = "\0" * 5
+ end
+
+ def test_drain
+ @fifo.write 'hello there'
+
+ @fifo.drain 6
+
+ @fifo.read @buffer, 5
+
+ assert_equal 'there', @buffer
+ end
+
+ def test_inspect
+ @fifo.write 'hello'
+
+ assert_match %r%size 5 space 15%, @fifo.inspect
+ end
+
+ def test_read
+ @fifo.write 'hello'
+
+ @fifo.read @buffer, 5
+
+ assert_equal 'hello', @buffer
+ end
+
+ def test_realloc
+ @fifo.write 'hello there'
+
+ @fifo.realloc 30
+
+ assert_equal 11, @fifo.size
+ assert_equal 19, @fifo.space
+ end
+
+ def test_reset
+ @fifo.write 'hello there'
+
+ @fifo.reset
+
+ @fifo.write ' eric'
+
+ @fifo.read @buffer, 5
+
+ assert_equal ' eric', @buffer
+ end
+
+ def test_size
+ @fifo.write 'hello there'
+
+ assert_equal 11, @fifo.size
+ end
+
+ def test_space
+ @fifo.write 'hello there'
+
+ assert_equal 9, @fifo.space
+ end
+
+ def test_write
+ @fifo.write 'hello'
+
+ assert_equal 5, @fifo.size
+ end
+
+end
+

0 comments on commit 406bd3f

Please sign in to comment.