mirror of
https://github.com/alexkay/spek.git
synced 2025-06-06 10:23:25 +03:00
Test audio file demuxing
This commit is contained in:
parent
b2dea0178c
commit
8f5bc2ad39
@ -20,6 +20,7 @@
|
|||||||
#define SPEK_AUDIO_H_
|
#define SPEK_AUDIO_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class AudioFile;
|
class AudioFile;
|
||||||
@ -73,4 +74,8 @@ inline bool operator!(AudioError error) {
|
|||||||
return error == AudioError::OK;
|
return error == AudioError::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& os, AudioError error) {
|
||||||
|
return os << static_cast<int>(error);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,6 +7,7 @@ endif
|
|||||||
check_PROGRAMS = $(TESTS)
|
check_PROGRAMS = $(TESTS)
|
||||||
|
|
||||||
test_SOURCES = \
|
test_SOURCES = \
|
||||||
|
test-audio-info.cc \
|
||||||
test-utils.cc \
|
test-utils.cc \
|
||||||
test.cc \
|
test.cc \
|
||||||
test.h
|
test.h
|
||||||
|
BIN
tests/samples/1ch-96000Hz-24bps.flac
Normal file
BIN
tests/samples/1ch-96000Hz-24bps.flac
Normal file
Binary file not shown.
BIN
tests/samples/2ch-48000Hz-16bps.flac
Normal file
BIN
tests/samples/2ch-48000Hz-16bps.flac
Normal file
Binary file not shown.
57
tests/test-audio-info.cc
Normal file
57
tests/test-audio-info.cc
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* test-audio-info.cc
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Alexander Kojevnikov <alexander@kojevnikov.com>
|
||||||
|
*
|
||||||
|
* Spek is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Spek is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Spek. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "spek-audio.h"
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
struct FileInfo
|
||||||
|
{
|
||||||
|
std::string codec_name;
|
||||||
|
int bit_rate;
|
||||||
|
int sample_rate;
|
||||||
|
int bits_per_sample;
|
||||||
|
int channels;
|
||||||
|
double duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void test_file(const std::string& name, const FileInfo& info)
|
||||||
|
{
|
||||||
|
Audio audio;
|
||||||
|
auto file = audio.open("samples/" + name);
|
||||||
|
test("error", AudioError::OK, file->get_error());
|
||||||
|
test("codec", info.codec_name, file->get_codec_name());
|
||||||
|
test("bit rate", info.bit_rate, file->get_bit_rate());
|
||||||
|
test("sample rate", info.sample_rate, file->get_sample_rate());
|
||||||
|
test("bps", info.bits_per_sample, file->get_bits_per_sample());
|
||||||
|
test("channels", info.channels, file->get_channels());
|
||||||
|
test("duration", info.duration, file->get_duration());
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_audio_info()
|
||||||
|
{
|
||||||
|
std::map<std::string, FileInfo> files = {
|
||||||
|
{ "1ch-96000Hz-24bps.flac", {"FLAC (Free Lossless Audio Codec)", 0, 96000, 24, 1, 0.1} },
|
||||||
|
{ "2ch-48000Hz-16bps.flac", {"FLAC (Free Lossless Audio Codec)", 0, 48000, 16, 2, 0.1} },
|
||||||
|
};
|
||||||
|
for (const auto& item : files) {
|
||||||
|
run([&] () { test_file(item.first, item.second); }, "audio info: " + item.first);
|
||||||
|
}
|
||||||
|
}
|
@ -23,9 +23,11 @@ int g_total = 0;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
std::cerr << "-------------" << std::endl;
|
||||||
|
|
||||||
|
test_audio_info();
|
||||||
test_utils();
|
test_utils();
|
||||||
|
|
||||||
std::cerr << "-------------" << std::endl;
|
|
||||||
std::cerr << g_passes << "/" << g_total << " tests passed" << std::endl;
|
std::cerr << g_passes << "/" << g_total << " tests passed" << std::endl;
|
||||||
std::cerr << "-------------" << std::endl;
|
std::cerr << "-------------" << std::endl;
|
||||||
if (g_passes < g_total) {
|
if (g_passes < g_total) {
|
||||||
|
@ -40,6 +40,7 @@ template<class T> void test(const std::string& message, const T& expected, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_audio_info();
|
||||||
void test_utils();
|
void test_utils();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user