From d8c5cfb56e4dde81e1ded355f135ebfb7a222924 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 21 Apr 2017 15:05:42 +0300 Subject: [PATCH] Add test for Chunk and Music loading through RWops --- tests/live_mixer.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/live_mixer.cc b/tests/live_mixer.cc index 34baa8a..ca5a054 100644 --- a/tests/live_mixer.cc +++ b/tests/live_mixer.cc @@ -2,6 +2,7 @@ #include #include +#include #include "testing.h" #include "movetest.hh" @@ -26,6 +27,30 @@ BEGIN_TEST(int, char*[]) Chunk sound(TESTDATA_DIR "/test.ogg"); Music music(TESTDATA_DIR "/test.ogg"); + // RWops methods + { + auto rwops = RWops::FromFile(TESTDATA_DIR "/test.ogg"); + Chunk chunk_by_rw(rwops); + + EXPECT_TRUE(chunk_by_rw.Get()); + + rwops.Seek(0, RW_SEEK_SET); + Music music_by_rw1(rwops); + + EXPECT_TRUE(music_by_rw1.Get()); + EXPECT_EQUAL(music_by_rw1.GetType(), MUS_OGG); + + rwops.Seek(0, RW_SEEK_SET); + Music music_by_rw2(rwops, MUS_OGG); + + EXPECT_TRUE(music_by_rw2.Get()); + EXPECT_EQUAL(music_by_rw2.GetType(), MUS_OGG); + + // bad format + rwops.Seek(0, RW_SEEK_SET); + EXPECT_EXCEPTION(Music(rwops, MUS_WAV), Exception); + } + MOVE_TEST(Chunk, sound, Get, nullptr); MOVE_TEST(Music, music, Get, nullptr);