test/test_flv.rb in flvedit-0.7.0 vs test/test_flv.rb in flvedit-0.7.1
- old
+ new
@@ -14,11 +14,11 @@
should "convert between #{s} and #{n} ms" do
assert_equal s, FLV::Timestamp.in_milliseconds(n).to_s
assert_equal n, FLV::Timestamp.try_convert(s).in_milliseconds
end
end
-
+
{ "0" => 0 ,
"1" => 1000,
"1.0" => 1000,
"1m" => 60_000,
"1h" => 60 * 60_000,
@@ -29,11 +29,11 @@
assert_equal n, FLV::Timestamp.try_convert(s).in_milliseconds
end
end
end
end
-
+
context "TimestampRange" do
context "conversion" do
{ "1:02-" => 62..(1/0.0),
"-1.23" => 0..1.23,
"12345-1:02:03.456" => 12345..3723.456,
@@ -43,12 +43,12 @@
assert_equal r, FLV::TimestampRange.try_convert(s).in_seconds
end
end
end
end
+
-
BIT_TEST = "\x01\x02\xff"
context "Bit reading from #{BIT_TEST.inspect}" do
setup do
@body = BIT_TEST.clone
class <<@body
@@ -70,11 +70,11 @@
should "return #{val} for bits #{bits}" do
assert_equal val, @body.read_bits(bits)
end
end
end
-
+
context "Packing" do
context "a header" do
setup do
@header = FLV::Header.new
@header.extra = "hello"
@@ -114,10 +114,30 @@
should "read just what's required" do
assert_equal "!!", @io.read
end
end
+ context "Packing + Unpacking" do
+ should "return the same object" do
+ obj = {
+ :event => "onMetaData" ,
+ :audiocodecid => 2 ,
+ :audiodatarate => 15.7066666666667 ,
+ :canSeekToEnd => false ,
+ :hasAudio => true ,
+ :cuePoints => [] ,
+ :keyframes => {:filepositions=>[846, 1968], :times=>[0.0, 0.2]},
+ :metadatadate => Time.gm(2000,"jan",1,20,15,1)
+ }
+ io = StringIO.new("").packed
+ io.write(obj, :flv_value)
+ io.rewind
+ assert_equal(obj, io.read(:flv_value))
+ assert io.eof?
+ end
+ end
+
context "Typematch" do
setup do
@chunks = FLV::File.open(SHORT_FLV).each.first(4)
end
@@ -139,7 +159,7 @@
should "work for #{check}" do
assert_equal answers, @chunks.map{|t| t.is?(check) }, check
end
end
end
-
+
end
\ No newline at end of file