Skip to content

Commit 08a62fc

Browse files
committed
Fix tests which weren't actually testing anything
1 parent 7ae50bd commit 08a62fc

6 files changed

+19
-18
lines changed

test/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ if (DEFINED BUILD_FOR_LINUX)
4949
add_executable(tests
5050
audio/output_test.cpp
5151

52-
audio/array/AudioArrayFixture.h
52+
# audio/array/AudioArrayFixture.h
5353
audio/array/test_array_mono_loop_backward_playback.cpp
5454
audio/array/test_array_mono_loop_forward_playback.cpp
5555
audio/array/test_array_stereo_loop_backward_playback.cpp
5656
audio/array/test_array_stereo_loop_forward_playback.cpp
5757

58-
audio/wav/AudioWavFixture.h
58+
# audio/wav/AudioWavFixture.h
5959
audio/wav/test_wav_mono_loop_forward_playback.cpp
6060
audio/wav/test_wav_stereo_loop_forward_playback.cpp
6161
audio/wav/test_wav_tags.cpp
6262

63-
low_level/sd/ResamplingReaderFixture.h
63+
# low_level/sd/ResamplingReaderFixture.h
6464
low_level/sd/test_raw_mono_noloop_forward_playback.cpp
6565
low_level/sd/test_raw_mono_noloop_forward_double_rate_playback.cpp
6666
low_level/sd/test_raw_mono_loop_forward_playback.cpp

test/low_level/array/test_array_mono_loop_forward_playback.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ BOOST_AUTO_TEST_SUITE(test_array_mono_loop_forward_playback)
1616

1717
BOOST_FIXTURE_TEST_CASE(ReadForwardLoopAtRegularPlaybackRate, ResamplingArrayFixture) {
1818

19-
const uint32_t expectedDataSize = kick_raw_len; // 32 16bit samples = 64 bytes of space
19+
const uint32_t expectedDataSize = kick_raw_len/2; // 32 16bit samples = 64 bytes of space
2020
printTest(expectedDataSize);
2121
//printf("ReadForwardAtRegularPlaybackRate(%d)\n", expectedDataSize);
2222

@@ -36,10 +36,10 @@ BOOST_AUTO_TEST_SUITE(test_array_mono_loop_forward_playback)
3636
//printf("j:%d bytesRead: %d \n", j, bytesRead);
3737
//printf("\n");
3838
j++;
39-
} while (j < 3);
39+
} while (bytesRead > 0);
4040
printf("total_bytes_read: %d \n", total_bytes_read);
4141
resamplingArrayReader->close();
42-
BOOST_CHECK_EQUAL(true, true);
42+
BOOST_CHECK_EQUAL(expectedDataSize, total_bytes_read);
4343
}
4444

4545
BOOST_AUTO_TEST_SUITE_END()

test/low_level/array/test_array_stereo_loop_forward_playback.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
extern unsigned char stereo_souljah_raw[];
1414
extern unsigned int stereo_souljah_raw_len;
1515
BOOST_AUTO_TEST_SUITE(test_array_stereo_loop_forward_playback)
16-
16+
/*
1717
unsigned char stereo_raw[] = {
1818
0x00, 0x00, 0x10, 0x00,
1919
0x01, 0x00, 0x11, 0x00,
@@ -23,16 +23,16 @@ BOOST_AUTO_TEST_SUITE(test_array_stereo_loop_forward_playback)
2323
0x05, 0x00, 0x15, 0x00 };
2424
2525
unsigned int stereo_raw_length = 24;
26-
26+
*/
2727
BOOST_FIXTURE_TEST_CASE(ReadForwardLoopAtRegularPlaybackRate, ResamplingArrayFixture) {
2828

29-
const uint32_t expectedDataSize = stereo_souljah_raw_len; // 32 16bit samples = 64 bytes of space
29+
const uint32_t expectedDataSize = stereo_souljah_raw_len/2; // stereo
3030
printTest(expectedDataSize);
3131
//printf("ReadForwardAtRegularPlaybackRate(%d)\n", expectedDataSize);
3232

3333
resamplingArrayReader->begin();
3434
resamplingArrayReader->setPlaybackRate(0.5f);
35-
resamplingArrayReader->playRaw((int16_t*)stereo_raw, stereo_raw_length/4, 1);
35+
resamplingArrayReader->playRaw((int16_t*)stereo_souljah_raw, stereo_souljah_raw_len/4, 2);
3636
BOOST_CHECK_EQUAL(resamplingArrayReader->isPlaying(), true);
3737
resamplingArrayReader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_none);
3838
int16_t actual_left[256];
@@ -46,10 +46,10 @@ BOOST_AUTO_TEST_SUITE(test_array_stereo_loop_forward_playback)
4646
total_bytes_read += bytesRead;
4747
//printf("j:%d bytesRead: %d \n", j, bytesRead);
4848
j++;
49-
} while (j < 3);
49+
} while (bytesRead > 0);
5050
printf("total_bytes_read: %d \n", total_bytes_read);
5151
resamplingArrayReader->close();
52-
BOOST_CHECK_EQUAL(true, true);
52+
BOOST_CHECK_EQUAL(expectedDataSize, total_bytes_read);
5353
}
5454

5555
BOOST_AUTO_TEST_SUITE_END()

test/low_level/arraywav/test_array_mono_loop_forward_playback.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ BOOST_AUTO_TEST_SUITE(test_array_mono)
1616

1717
BOOST_FIXTURE_TEST_CASE(ReadForwardLoopAtRegularPlaybackRate, ResamplingArrayWavFixture) {
1818

19-
const uint32_t expectedDataSize = mono_souljah_wav_len; // 32 16bit samples = 64 bytes of space
19+
const uint32_t expectedDataSize = mono_souljah_wav_len - WAV_HEADER_SIZE; // 32 16bit samples = 64 bytes of space
2020
printTest(expectedDataSize);
2121
//printf("ReadForwardAtRegularPlaybackRate(%d)\n", expectedDataSize);
2222

2323
resamplingArrayReader->begin();
2424
resamplingArrayReader->setPlaybackRate(0.5f);
25-
resamplingArrayReader->playWav((int16_t*)mono_souljah_wav, mono_souljah_wav_len/2);
25+
resamplingArrayReader->playWav((int16_t*)mono_souljah_wav /*, mono_souljah_wav_len/2 */);
2626
BOOST_CHECK_EQUAL(resamplingArrayReader->isPlaying(), true);
2727
resamplingArrayReader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_linear);
2828
int16_t actual[256];
@@ -39,7 +39,7 @@ BOOST_AUTO_TEST_SUITE(test_array_mono)
3939
} while (bytesRead > 0);
4040
printf("total_bytes_read: %d \n", total_bytes_read);
4141
resamplingArrayReader->close();
42-
BOOST_CHECK_EQUAL(true, true);
42+
BOOST_CHECK_EQUAL(expectedDataSize, total_bytes_read);
4343
}
4444

4545
BOOST_AUTO_TEST_SUITE_END()

test/low_level/arraywav/test_array_stereo_loop_forward_playback.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ BOOST_AUTO_TEST_SUITE(test_array_stereo)
1616

1717
BOOST_FIXTURE_TEST_CASE(ReadForwardLoopAtRegularPlaybackRate, ResamplingArrayWavFixture) {
1818

19-
const uint32_t expectedDataSize = stereo_souljah_wav_len; // 32 16bit samples = 64 bytes of space
19+
const uint32_t expectedDataSize = (stereo_souljah_wav_len - WAV_HEADER_SIZE)/4;
2020
printTest(expectedDataSize);
2121
//printf("ReadForwardAtRegularPlaybackRate(%d)\n", expectedDataSize);
2222

2323
resamplingArrayReader->begin();
2424
resamplingArrayReader->setPlaybackRate(1.0f);
25-
resamplingArrayReader->playWav((int16_t*)stereo_souljah_wav, stereo_souljah_wav_len/2);
25+
resamplingArrayReader->playWav((int16_t*)stereo_souljah_wav/*, stereo_souljah_wav_len/2 */);
2626
BOOST_CHECK_EQUAL(resamplingArrayReader->isPlaying(), true);
2727
resamplingArrayReader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_linear);
2828
int16_t actualLeft[256], actualRight[256];
@@ -39,7 +39,7 @@ BOOST_AUTO_TEST_SUITE(test_array_stereo)
3939
} while (bytesRead > 0);
4040
printf("total_bytes_read: %d \n", total_bytes_read);
4141
resamplingArrayReader->close();
42-
BOOST_CHECK_EQUAL(true, true);
42+
BOOST_CHECK_EQUAL(expectedDataSize, total_bytes_read);
4343
}
4444

4545
BOOST_AUTO_TEST_SUITE_END()

test/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define PRINT_ALL_SAMPLES false
22
#define NO_RATE -1.0
33
#define LOOP_BLOCKS 42 // number of blocks to generate when looping
4+
#define WAV_HEADER_SIZE 44 // sleazy hack...
45

56
#define REFERENCE_PATH "../../test/resources/reference/"
67
#define INPUT_PATH "../../test/resources/input"

0 commit comments

Comments
 (0)