spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit eb1abe827e3579a7f7e47419b05ba8d54b28bf3c
parent b5fcfface151f778f296184522940af379a3ecf3
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Wed, 27 Mar 2013 09:05:04 -0700

tests: Missing audio file

Diffstat:
Msrc/spek-audio.cc | 6+++---
Mtests/test-audio-info.cc | 30++++++++++++++++--------------
2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/spek-audio.cc b/src/spek-audio.cc @@ -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; diff --git a/tests/test-audio-info.cc b/tests/test-audio-info.cc @@ -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(