Browse Source

WavAudioImporter: test for empty files consistently with other plugins.

pull/343/head
Vladimír Vondruš 7 years ago
parent
commit
3d9966378d
  1. 16
      src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp

16
src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp

@ -40,7 +40,7 @@ namespace Magnum { namespace Audio { namespace Test { namespace {
struct WavImporterTest: TestSuite::Tester { struct WavImporterTest: TestSuite::Tester {
explicit WavImporterTest(); explicit WavImporterTest();
void wrongSize(); void empty();
void wrongSignature(); void wrongSignature();
void unsupportedFormat(); void unsupportedFormat();
void unsupportedChannelCount(); void unsupportedChannelCount();
@ -80,7 +80,7 @@ struct WavImporterTest: TestSuite::Tester {
}; };
WavImporterTest::WavImporterTest() { WavImporterTest::WavImporterTest() {
addTests({&WavImporterTest::wrongSize, addTests({&WavImporterTest::empty,
&WavImporterTest::wrongSignature, &WavImporterTest::wrongSignature,
&WavImporterTest::unsupportedFormat, &WavImporterTest::unsupportedFormat,
&WavImporterTest::unsupportedChannelCount, &WavImporterTest::unsupportedChannelCount,
@ -122,13 +122,15 @@ WavImporterTest::WavImporterTest() {
#endif #endif
} }
void WavImporterTest::wrongSize() { void WavImporterTest::empty() {
Containers::Pointer<AbstractImporter> importer = _manager.instantiate("WavAudioImporter");
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
char a{};
Containers::Pointer<AbstractImporter> importer = _manager.instantiate("WavAudioImporter"); /* Explicitly checking non-null but empty view */
CORRADE_VERIFY(!importer->openData(Containers::Array<char>(43))); CORRADE_VERIFY(!importer->openData({&a, 0}));
CORRADE_COMPARE(out.str(), "Audio::WavImporter::openData(): the file is too short: 43 bytes\n"); CORRADE_COMPARE(out.str(), "Audio::WavImporter::openData(): the file is too short: 0 bytes\n");
} }
void WavImporterTest::wrongSignature() { void WavImporterTest::wrongSignature() {

Loading…
Cancel
Save