Made Ogg::Vorbis::Tagger#close return nil.
[ruby-vorbistagger.git] / test / test_main.rb
index bbc5b0023a2987e31af883c4573dde96f4605dd5..6355e7e9d23fca663d55283d059b51f427a71804 100644 (file)
@@ -252,4 +252,37 @@ EOF
        def test_close
                Ogg::Vorbis::Tagger.new(OGG_FILE).close
        end
+
+       def test_close2
+               t = Ogg::Vorbis::Tagger.new(OGG_FILE)
+               t.close
+
+               assert_raise(Ogg::Vorbis::Tagger::ClosedStreamError) do
+                       t.close
+               end
+
+               assert_raise(Ogg::Vorbis::Tagger::ClosedStreamError) do
+                       Ogg::Vorbis::Tagger.open(OGG_FILE) do |t|
+                               t.close
+                       end
+               end
+       end
+
+       def test_open_non_existing_file
+               assert_raises(Ogg::Vorbis::Tagger::OpenError) do
+                       Ogg::Vorbis::Tagger.new("foo.bar")
+               end
+       end
+
+       def test_open_non_ogg_file
+               File.open("test/foo.bar", "w") do |f|
+                       f << "foobarbazxyzzy"
+               end
+
+               assert_raises(Ogg::Vorbis::Tagger::InvalidDataError) do
+                       Ogg::Vorbis::Tagger.new("test/foo.bar")
+               end
+       ensure
+               FileUtils.rm_f("test/foo.bar")
+       end
 end