From 9f770629606ca58c78b411e73696eec275c328a5 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 28 Jan 2016 17:03:18 +0100 Subject: Conform to style guide. --- test/audiocacheeventhandlertest.cc | 16 +++------- test/audiocachefiletest.cc | 64 ++++++++++++++++++++------------------ test/audiocacheidmanagertest.cc | 7 +++-- test/audiocachetest.cc | 49 +++++++++++++++-------------- 4 files changed, 68 insertions(+), 68 deletions(-) (limited to 'test') diff --git a/test/audiocacheeventhandlertest.cc b/test/audiocacheeventhandlertest.cc index a8c3777..5f30d2e 100644 --- a/test/audiocacheeventhandlertest.cc +++ b/test/audiocacheeventhandlertest.cc @@ -28,14 +28,8 @@ #include -class TestableAudioCacheEventHandler - : public AudioCacheEventHandler -{ -public: - -}; - -class AudioCacheEventHandlerTest : public CppUnit::TestFixture +class AudioCacheEventHandlerTest + : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(AudioCacheEventHandlerTest); CPPUNIT_TEST(threadedTest); @@ -47,10 +41,10 @@ public: void threadedTest() { - AudioCacheIDManager idManager; - idManager.init(10); + AudioCacheIDManager id_manager; + id_manager.init(10); - AudioCacheEventHandler eventHandler(idManager); + AudioCacheEventHandler event_handler(id_manager); } }; diff --git a/test/audiocachefiletest.cc b/test/audiocachefiletest.cc index 4945ade..98b7ab5 100644 --- a/test/audiocachefiletest.cc +++ b/test/audiocachefiletest.cc @@ -31,7 +31,8 @@ #include #include -class TestableAudioCacheFiles : public AudioCacheFiles +class TestableAudioCacheFiles + : public AudioCacheFiles { public: //CacheAudioFile& getAudioFile(const std::string& filename); @@ -47,7 +48,8 @@ public: } }; -class AudioCacheFileTest : public CppUnit::TestFixture +class AudioCacheFileTest + : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(AudioCacheFileTest); CPPUNIT_TEST(refTest); @@ -78,16 +80,16 @@ public: CPPUNIT_ASSERT_EQUAL(-1, audiofiles.getRef(filename)); } - void readTestHelper(size_t bufferSize) + void readTestHelper(size_t buffer_size) { - printf("Test buffer size: %d samples\n", (int)bufferSize); + printf("Test buffer size: %d samples\n", (int)buffer_size); std::string filename = "kit/ride-multi-channel.wav"; - AudioFile* refFile[13]; + AudioFile* ref_file[13]; for(size_t c = 0; c < 13; ++c) { - refFile[c] = new AudioFile(filename, c); - refFile[c]->load(); + ref_file[c] = new AudioFile(filename, c); + ref_file[c]->load(); } AudioCacheFile file(filename); @@ -96,11 +98,11 @@ public: CacheChannels channels; - sample_t samples[13][bufferSize]; + sample_t samples[13][buffer_size]; volatile bool ready[13]; for(size_t c = 0; c < 13; ++c) { - for(size_t i = 0; i < bufferSize; ++i) + for(size_t i = 0; i < buffer_size; ++i) { samples[c][i] = 42; } @@ -109,30 +111,30 @@ public: { c, // channel samples[c], // samples - bufferSize, // max_num_samples + buffer_size, // max_num_samples &ready[c] // ready } ); } - for(size_t offset = 0; offset < file.getSize(); offset += bufferSize) + for(size_t offset = 0; offset < file.getSize(); offset += buffer_size) { for(size_t c = 0; c < 13; ++c) { ready[c] = false; } - size_t readSize = file.getSize() - offset; - if(readSize > bufferSize) + size_t read_size = file.getSize() - offset; + if(read_size > buffer_size) { - readSize = bufferSize; + read_size = buffer_size; } else { - printf("Last read: %d samples\n", (int)readSize); + printf("Last read: %d samples\n", (int)read_size); } - file.readChunk(channels, offset, readSize); + file.readChunk(channels, offset, read_size); for(size_t c = 0; c < 13; ++c) { @@ -142,9 +144,9 @@ public: sample_t diff[13] = {0.0}; for(size_t c = 0; c < 13; ++c) { - for(size_t i = 0; i < readSize; ++i) + for(size_t i = 0; i < read_size; ++i) { - diff[c] += abs(refFile[c]->data[i + offset] - samples[c][i]); + diff[c] += abs(ref_file[c]->data[i + offset] - samples[c][i]); } } @@ -156,34 +158,34 @@ public: for(size_t c = 0; c < 13; ++c) { - delete refFile[c]; + delete ref_file[c]; } } void readTest() { // Exhaustive test for 1...64 - for(size_t bufferSize = 1; bufferSize < 64; ++bufferSize) + for(size_t buffer_size = 1; buffer_size < 64; ++buffer_size) { - readTestHelper(bufferSize); + readTestHelper(buffer_size); } // Binary test for 64 .. 4096 - for(size_t bufferSize = 64; bufferSize < 4096; bufferSize *= 2) + for(size_t buffer_size = 64; buffer_size < 4096; buffer_size *= 2) { - readTestHelper(bufferSize); + readTestHelper(buffer_size); } // And some sporadic tests for some "wierd" sizes. - for(size_t bufferSize = 65; bufferSize < 4096; bufferSize *= 1.1) + for(size_t buffer_size = 65; buffer_size < 4096; buffer_size *= 1.1) { - readTestHelper(bufferSize); + readTestHelper(buffer_size); } } void noFileTest() { - size_t bufferSize = 64; + size_t buffer_size = 64; std::string filename = "kits/no-such-file.wav"; AudioCacheFile file(filename); @@ -193,11 +195,11 @@ public: CacheChannels channels; - sample_t samples[13][bufferSize]; + sample_t samples[13][buffer_size]; volatile bool ready[13]; for(size_t c = 0; c < 13; ++c) { - for(size_t i = 0; i < bufferSize; ++i) + for(size_t i = 0; i < buffer_size; ++i) { samples[c][i] = 42.0f; } @@ -206,7 +208,7 @@ public: { c, // channel samples[c], // samples - bufferSize, // max_num_samples + buffer_size, // max_num_samples &ready[c] // ready } ); @@ -217,7 +219,7 @@ public: ready[c] = false; } - file.readChunk(channels, 0, bufferSize); + file.readChunk(channels, 0, buffer_size); for(size_t c = 0; c < 13; ++c) { @@ -226,7 +228,7 @@ public: for(size_t c = 0; c < 13; ++c) { - for(size_t i = 0; i < bufferSize; ++i) + for(size_t i = 0; i < buffer_size; ++i) { CPPUNIT_ASSERT_EQUAL(42.0f, samples[c][i]); } diff --git a/test/audiocacheidmanagertest.cc b/test/audiocacheidmanagertest.cc index ae8bfbc..a9cc878 100644 --- a/test/audiocacheidmanagertest.cc +++ b/test/audiocacheidmanagertest.cc @@ -28,7 +28,9 @@ #include -class TestableAudioCacheIDManager : public AudioCacheIDManager { +class TestableAudioCacheIDManager + : public AudioCacheIDManager +{ public: int getAvailableIDs() { @@ -36,7 +38,8 @@ public: } }; -class AudioCacheIDManagerTest : public CppUnit::TestFixture +class AudioCacheIDManagerTest + : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(AudioCacheIDManagerTest); CPPUNIT_TEST(registerReleaseTest); diff --git a/test/audiocachetest.cc b/test/audiocachetest.cc index 157cc03..5db5940 100644 --- a/test/audiocachetest.cc +++ b/test/audiocachetest.cc @@ -32,7 +32,8 @@ #define FRAMESIZE 64 -class AudioCacheTest : public CppUnit::TestFixture +class AudioCacheTest + : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(AudioCacheTest); CPPUNIT_TEST(singleChannelNonThreaded); @@ -54,22 +55,22 @@ public: int framesize) { // Reference file: - AudioFile audioFileRef(filename, channel); - printf("audioFileRef.load\n"); - audioFileRef.load(ALL_SAMPLES); + AudioFile audio_file_ref(filename, channel); + printf("audio_file_ref.load\n"); + audio_file_ref.load(ALL_SAMPLES); // Input file: - AudioFile audioFile(filename, channel); - printf("audioFile.load\n"); - audioFile.load(4096); + AudioFile audio_file(filename, channel); + printf("audio_file.load\n"); + audio_file.load(4096); - AudioCache audioCache; - printf("audioCache.init\n"); - audioCache.init(100); - audioCache.setAsyncMode(threaded); + AudioCache audio_cache; + printf("audio_cache.init\n"); + audio_cache.init(100); + audio_cache.setAsyncMode(threaded); // Set initial (upper limit) framesize - audioCache.setFrameSize(framesize); + audio_cache.setFrameSize(framesize); cacheid_t id; @@ -80,25 +81,25 @@ public: printf("open: initial_samples_needed: %d\n", (int)initial_samples_needed); sample_t *samples = - audioCache.open(&audioFile, initial_samples_needed, channel, id); + audio_cache.open(&audio_file, initial_samples_needed, channel, id); size_t size = initial_samples_needed; size_t offset = 0; // Test pre cache: for(size_t i = 0; i < size; ++i) { - CPPUNIT_ASSERT_EQUAL(audioFileRef.data[offset], samples[i]); + CPPUNIT_ASSERT_EQUAL(audio_file_ref.data[offset], samples[i]); ++offset; } // Test the rest - while(offset < audioFileRef.size) + while(offset < audio_file_ref.size) { if(threaded) { // Wait until we are finished reading int timeout = 1000; - while(!audioCache.isReady(id)) + while(!audio_cache.isReady(id)) { usleep(1000); if(--timeout == 0) @@ -108,26 +109,26 @@ public: } } - samples = audioCache.next(id, size); + samples = audio_cache.next(id, size); - CPPUNIT_ASSERT_EQUAL(0, (int)audioCache.getNumberOfUnderruns()); + CPPUNIT_ASSERT_EQUAL(0, (int)audio_cache.getNumberOfUnderruns()); - for(size_t i = 0; (i < size) && (offset < audioFileRef.size); ++i) + for(size_t i = 0; (i < size) && (offset < audio_file_ref.size); ++i) { - if(audioFileRef.data[offset] != samples[i]) + if(audio_file_ref.data[offset] != samples[i]) { printf("-----> offset: %d, size: %d, diff: %d," " i: %d, size: %d, block-diff: %d\n", - (int)offset, (int)audioFileRef.size, - (int)(audioFileRef.size - offset), + (int)offset, (int)audio_file_ref.size, + (int)(audio_file_ref.size - offset), (int)i, (int)size, (int)(size - i)); } - CPPUNIT_ASSERT_EQUAL(audioFileRef.data[offset], samples[i]); + CPPUNIT_ASSERT_EQUAL(audio_file_ref.data[offset], samples[i]); ++offset; } } - audioCache.close(id); + audio_cache.close(id); } printf("done\n"); -- cgit v1.2.3