ruby-ogginfo 0.7 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/Rakefile +2 -1
- data/lib/ogg/codecs/comments.rb +5 -2
- data/lib/ogginfo.rb +1 -1
- data/test/fixtures.yml +1115 -1114
- data/test/test_ruby-ogginfo.rb +0 -48
- data/test/test_ruby-othercodecs.rb +63 -7
- metadata +1 -1
data/test/test_ruby-ogginfo.rb
CHANGED
@@ -34,35 +34,6 @@ class OggInfoTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def test_writing_to_spedial_filenames
|
38
|
-
filename = "fichier éé.ogg"
|
39
|
-
FileUtils.cp(@tempfile, filename)
|
40
|
-
begin
|
41
|
-
OggInfo.open(@tempfile) do |ogg|
|
42
|
-
ogg.tag.title = "a"*200
|
43
|
-
end
|
44
|
-
#system("ls", "-l", filename)
|
45
|
-
ensure
|
46
|
-
FileUtils.rm_f(filename)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_good_writing_of_utf8_strings
|
51
|
-
tag = { "title" => "this is a éé utf8 string",
|
52
|
-
"artist" => "and è another one à"}
|
53
|
-
tag_test("tag_writing", tag)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_tag_writing
|
57
|
-
data = "a"*256
|
58
|
-
tag_test("tag_writing", "title" => data, "artist" => data )
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_big_tags
|
62
|
-
data = "a"*60000
|
63
|
-
tag_test("big_tags", "title" => data, "artist" => data )
|
64
|
-
end
|
65
|
-
|
66
37
|
def test_should_not_fail_when_input_is_truncated
|
67
38
|
ogg_length = nil
|
68
39
|
OggInfo.open(@tempfile) do |ogg|
|
@@ -134,23 +105,4 @@ class OggInfoTest < Test::Unit::TestCase
|
|
134
105
|
tf.close
|
135
106
|
tf
|
136
107
|
end
|
137
|
-
|
138
|
-
def tag_test(test_name, tag)
|
139
|
-
OggInfo.open(@tempfile) do |ogg|
|
140
|
-
tag.each { |k,v| ogg.tag[k] = v }
|
141
|
-
end
|
142
|
-
|
143
|
-
OggInfo.open(@tempfile) do |ogg|
|
144
|
-
assert_equal tag, ogg.tag
|
145
|
-
end
|
146
|
-
system("cp #{@tempfile} /tmp/test_#{RUBY_VERSION}_#{test_name}.ogg")
|
147
|
-
test_length
|
148
|
-
assert_nothing_raised do
|
149
|
-
io = open(@tempfile)
|
150
|
-
reader = Ogg::Reader.new(io)
|
151
|
-
reader.each_pages do |page|
|
152
|
-
page
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
108
|
end
|
@@ -9,17 +9,14 @@ require "tempfile"
|
|
9
9
|
require File.join(File.dirname(__FILE__), "test_helper")
|
10
10
|
|
11
11
|
class OtherCodecsInfoTest < Test::Unit::TestCase
|
12
|
-
CODECS = [:speex, :opus]
|
13
|
-
|
14
12
|
def setup
|
15
13
|
@fixtures = load_fixtures
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_generated_info
|
19
|
-
|
20
|
-
OggInfo.open(
|
17
|
+
@fixtures.each do |codec, tempfile|
|
18
|
+
OggInfo.open(tempfile) do |ogg|
|
21
19
|
assert_equal 2, ogg.channels
|
22
|
-
assert_equal 48000, ogg.samplerate
|
23
20
|
case codec
|
24
21
|
when :speex
|
25
22
|
assert_equal "spxinfotest", ogg.tag.author
|
@@ -27,15 +24,21 @@ class OtherCodecsInfoTest < Test::Unit::TestCase
|
|
27
24
|
assert_in_delta(3, ogg.length, 0.2, "length has not been correctly guessed for codec \"#{codec}\"")
|
28
25
|
assert_in_delta 64000, ogg.bitrate, 2000
|
29
26
|
assert_equal "artist", ogg.tag.artist
|
27
|
+
assert_equal 48000, ogg.samplerate
|
28
|
+
when :ogg
|
29
|
+
assert_in_delta(3, ogg.length, 0.5, "length has not been correctly guessed for codec \"#{codec}\"")
|
30
|
+
assert_in_delta 64000, ogg.bitrate, 10000
|
31
|
+
assert_equal "artist", ogg.tag.artist
|
32
|
+
assert_equal 44100, ogg.samplerate
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
38
|
def test_tag_writing
|
36
|
-
|
39
|
+
@fixtures.each do |codec, tempfile|
|
37
40
|
tag = {"title" => "mytitle", "test" => "myartist" }
|
38
|
-
OggInfo.open(
|
41
|
+
OggInfo.open(tempfile) do |ogg|
|
39
42
|
ogg.tag.clear
|
40
43
|
tag.each { |k,v| ogg.tag[k] = v }
|
41
44
|
end
|
@@ -45,4 +48,57 @@ class OtherCodecsInfoTest < Test::Unit::TestCase
|
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
51
|
+
|
52
|
+
def test_good_writing_of_utf8_strings
|
53
|
+
tag = { "title" => "this is a éé utf8 string",
|
54
|
+
"artist" => "and è another one à"}
|
55
|
+
tag_test("tag_writing", tag)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_tag_writing
|
59
|
+
data = "a"*256
|
60
|
+
tag_test("tag_writing", "title" => data, "artist" => data )
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_big_tags
|
64
|
+
data = "a"*60000
|
65
|
+
tag_test("big_tags", "title" => data, "artist" => data )
|
66
|
+
end
|
67
|
+
|
68
|
+
def tag_test(test_name, tag)
|
69
|
+
@fixtures.each do |codec, tempfile|
|
70
|
+
OggInfo.open(tempfile) do |ogg|
|
71
|
+
ogg.tag.clear
|
72
|
+
tag.each { |k,v| ogg.tag[k] = v }
|
73
|
+
end
|
74
|
+
|
75
|
+
OggInfo.open(tempfile) do |ogg|
|
76
|
+
assert_equal tag, ogg.tag
|
77
|
+
end
|
78
|
+
FileUtils.cp(tempfile, "/tmp/test_#{RUBY_VERSION}_#{test_name}.ogg")
|
79
|
+
assert_nothing_raised do
|
80
|
+
io = open(tempfile)
|
81
|
+
reader = Ogg::Reader.new(io)
|
82
|
+
reader.each_pages do |page|
|
83
|
+
page
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_unicode_support
|
90
|
+
@fixtures.each do |codec, tempfile|
|
91
|
+
filename = "fichier éé.#{codec}"
|
92
|
+
FileUtils.cp(tempfile, filename)
|
93
|
+
begin
|
94
|
+
OggInfo.open(tempfile) do |ogg|
|
95
|
+
ogg.tag.artist = "artistéoo"
|
96
|
+
ogg.tag.title = "a"*200
|
97
|
+
end
|
98
|
+
ensure
|
99
|
+
FileUtils.rm_f(filename)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
48
104
|
end
|