From 3d9966378d685927b993cb6b85d4f85fb8cd4de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 25 May 2019 21:19:10 +0200 Subject: [PATCH] WavAudioImporter: test for empty files consistently with other plugins. --- .../WavAudioImporter/Test/WavImporterTest.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp b/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp index 94ce7800b..473256ade 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp +++ b/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp @@ -40,7 +40,7 @@ namespace Magnum { namespace Audio { namespace Test { namespace { struct WavImporterTest: TestSuite::Tester { explicit WavImporterTest(); - void wrongSize(); + void empty(); void wrongSignature(); void unsupportedFormat(); void unsupportedChannelCount(); @@ -80,7 +80,7 @@ struct WavImporterTest: TestSuite::Tester { }; WavImporterTest::WavImporterTest() { - addTests({&WavImporterTest::wrongSize, + addTests({&WavImporterTest::empty, &WavImporterTest::wrongSignature, &WavImporterTest::unsupportedFormat, &WavImporterTest::unsupportedChannelCount, @@ -122,13 +122,15 @@ WavImporterTest::WavImporterTest() { #endif } -void WavImporterTest::wrongSize() { +void WavImporterTest::empty() { + Containers::Pointer importer = _manager.instantiate("WavAudioImporter"); + std::ostringstream out; Error redirectError{&out}; - - Containers::Pointer importer = _manager.instantiate("WavAudioImporter"); - CORRADE_VERIFY(!importer->openData(Containers::Array(43))); - CORRADE_COMPARE(out.str(), "Audio::WavImporter::openData(): the file is too short: 43 bytes\n"); + char a{}; + /* Explicitly checking non-null but empty view */ + CORRADE_VERIFY(!importer->openData({&a, 0})); + CORRADE_COMPARE(out.str(), "Audio::WavImporter::openData(): the file is too short: 0 bytes\n"); } void WavImporterTest::wrongSignature() {