diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index bbd4a61..d6271c6 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -4,13 +4,13 @@ set(adonthell_audio_SRCS sound.cc audio_event.cc audio_event_manager.cc - audio_manager.cc + audio_manager.cc ) set(adonthell_audio_HEADERS audio_event.h audio_event_manager.h - audio_manager.h + audio_manager.h audio.h sound.h ) @@ -50,4 +50,4 @@ set_target_properties(audio-backend-sdl PROPERTIES PREFIX "_" OUTPUT_NAME "sdl") # Install Stuff adonthell_install_lib(adonthell_audio) adonthell_install_include(audio "${adonthell_audio_HEADERS}") -adonthell_install_backend(audio audio-backend-sdl) \ No newline at end of file +adonthell_install_backend(audio audio-backend-sdl) diff --git a/src/audio/Makefile.am b/src/audio/Makefile.am index 88f55cd..5abad45 100644 --- a/src/audio/Makefile.am +++ b/src/audio/Makefile.am @@ -47,3 +47,11 @@ _sdl_la_LIBADD = $(SDL_LIBS) -lSDL_mixer -ladonthell_audio -lstdc++ ## define dependencies in case of parallel build _sdl_la_DEPENDENCIES = libadonthell_audio.la +## Unit tests +noinst_PROGRAMS = test_audio_manager + +test_audio_manager_SOURCES = $(libadonthell_audio_la_SOURCES) test_audio_manager.cc +test_audio_manager_CXXFLAGS = $(libadonthell_audio_la_CXXFLAGS) +test_audio_manager_LDADD = $(libadonthell_audio_la_LIBADD) -lgtest + +TESTS = test_audio_manager diff --git a/src/audio/audio_manager.cc b/src/audio/audio_manager.cc index 22b6d13..07bb556 100644 --- a/src/audio/audio_manager.cc +++ b/src/audio/audio_manager.cc @@ -33,6 +33,13 @@ namespace audio { + // Static data must be initialised + int audio_manager::audio_rate_; + u_int16 audio_manager::audio_format_; + int audio_manager::audio_channels_; + int audio_manager::audio_buffers_; + int audio_manager::audio_mixchannels_; + bool audio_manager::set_audio_rate(const int audio_rate) { audio_rate_ = audio_rate; diff --git a/src/test/audio/audio_manager.cc b/src/audio/test_audio_manager.cc similarity index 93% rename from src/test/audio/audio_manager.cc rename to src/audio/test_audio_manager.cc index fa26e34..87c4a7b 100644 --- a/src/test/audio/audio_manager.cc +++ b/src/audio/test_audio_manager.cc @@ -29,9 +29,9 @@ */ -#include +#include "audio/audio_manager.h" -#include "audio/audio_manager" +#include namespace audio { @@ -65,3 +65,10 @@ namespace audio } } // namespace{} + + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +}