tests: Missing audio file

This commit is contained in:
Alexander Kojevnikov 2013-03-27 09:05:04 -07:00
parent b5fcfface1
commit eb1abe827e
2 changed files with 19 additions and 17 deletions

View File

@ -103,9 +103,9 @@ std::unique_ptr<AudioFile> Audio::open(const std::string& file_name)
break;
}
}
}
if (audio_stream == -1) {
error = AudioError::NO_AUDIO;
if (audio_stream == -1) {
error = AudioError::NO_AUDIO;
}
}
AVStream *stream = nullptr;

View File

@ -24,6 +24,7 @@
struct FileInfo
{
AudioError error;
std::string codec_name;
int bit_rate;
int sample_rate;
@ -36,7 +37,7 @@ static void test_file(const std::string& name, const FileInfo& info)
{
Audio audio;
auto file = audio.open(SAMPLES_DIR "/" + name);
test("error", AudioError::OK, file->get_error());
test("error", info.error, file->get_error());
test(file->get_codec_name(), true, !file->get_codec_name().compare(
0, info.codec_name.length(), info.codec_name
));
@ -53,19 +54,20 @@ void test_audio_info()
const double M4A_T = (10240 + 628) / 2.0 / 44100;
std::map<std::string, FileInfo> files = {
{"1ch-96000Hz-24bps.flac", {"FLAC", 0, 96000, 24, 1, 0.1}},
{"2ch-48000Hz-16bps.flac", {"FLAC", 0, 48000, 16, 2, 0.1}},
{"1ch-96000Hz-24bps.ape", {"Monkey", 0, 96000, 24, 1, 0.1}},
{"2ch-48000Hz-16bps.ape", {"Monkey", 0, 48000, 16, 2, 0.1}},
{"1ch-96000Hz-24bps.wv", {"WavPack", 0, 96000, 24, 1, 0.1}},
{"2ch-48000Hz-16bps.wv", {"WavPack", 0, 48000, 16, 2, 0.1}},
{"2ch-44100Hz-16bps.wav", {"PCM", 0, 44100, 16, 2, 0.1}},
{"2ch-44100Hz-128cbr.mp3", {"MP3", 128000, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-320cbr.mp3", {"MP3", 320000, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-V0.mp3", {"MP3", 201329, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-V2.mp3", {"MP3", 150124, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-q100.m4a", {"AAC", 159649, 44100, 0, 2, M4A_T}},
{"2ch-44100Hz-q5.ogg", {"Vorbis", 160000, 44100, 0, 2, 0.1}},
{"no.file", {AudioError::CANNOT_OPEN_FILE, "", 0, 0, 0, 0, 0.0}},
{"1ch-96000Hz-24bps.flac", {AudioError::OK, "FLAC", 0, 96000, 24, 1, 0.1}},
{"2ch-48000Hz-16bps.flac", {AudioError::OK, "FLAC", 0, 48000, 16, 2, 0.1}},
{"1ch-96000Hz-24bps.ape", {AudioError::OK, "Monkey", 0, 96000, 24, 1, 0.1}},
{"2ch-48000Hz-16bps.ape", {AudioError::OK, "Monkey", 0, 48000, 16, 2, 0.1}},
{"1ch-96000Hz-24bps.wv", {AudioError::OK, "WavPack", 0, 96000, 24, 1, 0.1}},
{"2ch-48000Hz-16bps.wv", {AudioError::OK, "WavPack", 0, 48000, 16, 2, 0.1}},
{"2ch-44100Hz-16bps.wav", {AudioError::OK, "PCM", 0, 44100, 16, 2, 0.1}},
{"2ch-44100Hz-128cbr.mp3", {AudioError::OK, "MP3", 128000, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-320cbr.mp3", {AudioError::OK, "MP3", 320000, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-V0.mp3", {AudioError::OK, "MP3", 201329, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-V2.mp3", {AudioError::OK, "MP3", 150124, 44100, 0, 2, MP3_T}},
{"2ch-44100Hz-q100.m4a", {AudioError::OK, "AAC", 159649, 44100, 0, 2, M4A_T}},
{"2ch-44100Hz-q5.ogg", {AudioError::OK, "Vorbis", 160000, 44100, 0, 2, 0.1}},
};
for (const auto& item : files) {
run(