From 86c589d44a785a9a46b5991dae08beedfc121492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Nov 2019 20:46:17 +0100 Subject: [PATCH] Shorten assertion messages in Image{Data,View,} constructors. --- src/Magnum/Image.cpp | 2 +- src/Magnum/ImageView.cpp | 6 +++--- src/Magnum/Test/ImageTest.cpp | 6 +++--- src/Magnum/Test/ImageViewTest.cpp | 8 ++++---- src/Magnum/Trade/ImageData.cpp | 2 +- src/Magnum/Trade/Test/ImageDataTest.cpp | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Magnum/Image.cpp b/src/Magnum/Image.cpp index 4b18e3ab9..30be47f01 100644 --- a/src/Magnum/Image.cpp +++ b/src/Magnum/Image.cpp @@ -36,7 +36,7 @@ template Image::Image(const PixelStorage sto template Image::Image(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, pixelFormatWrap(format), formatExtra, pixelSize, size, std::move(data)} {} template Image::Image(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, Containers::Array&& data) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _size{size}, _data{std::move(data)} { - CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "Image::Image(): data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); + CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "Image: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); } template Image::Image(const PixelStorage storage, const PixelFormat format) noexcept: Image{storage, format, {}, Magnum::pixelSize(format)} {} diff --git a/src/Magnum/ImageView.cpp b/src/Magnum/ImageView.cpp index b8bd542a3..805bc7b28 100644 --- a/src/Magnum/ImageView.cpp +++ b/src/Magnum/ImageView.cpp @@ -38,11 +38,11 @@ template ImageView::ImageView(co #ifdef MAGNUM_BUILD_DEPRECATED #ifndef CORRADE_NO_ASSERT if(size.product() && !_data && !_data.size()) - Warning{} << "ImageView::ImageView(): passing empty data to a non-empty view is deprecated, use a constructor without the data parameter instead"; + Warning{} << "ImageView: passing empty data to a non-empty view is deprecated, use a constructor without the data parameter instead"; #endif - CORRADE_ASSERT(!_data || Implementation::imageDataSize(*this) <= _data.size(), "ImageView::ImageView(): data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); + CORRADE_ASSERT(!_data || Implementation::imageDataSize(*this) <= _data.size(), "ImageView: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); #else - CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "ImageView::ImageView(): data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); + CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "ImageView: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); #endif } diff --git a/src/Magnum/Test/ImageTest.cpp b/src/Magnum/Test/ImageTest.cpp index 22e3ebef1..8891674a8 100644 --- a/src/Magnum/Test/ImageTest.cpp +++ b/src/Magnum/Test/ImageTest.cpp @@ -416,7 +416,7 @@ void ImageTest::constructInvalidSize() { /* Doesn't consider alignment */ Image2D{PixelFormat::RGB8Unorm, {1, 3}, Containers::Array{3*3}}; - CORRADE_COMPARE(out.str(), "Image::Image(): data too small, got 9 but expected at least 12 bytes\n"); + CORRADE_COMPARE(out.str(), "Image: data too small, got 9 but expected at least 12 bytes\n"); } void ImageTest::constructCompressedInvalidSize() { @@ -427,14 +427,14 @@ void ImageTest::constructCompressedInvalidSize() { std::ostringstream out; Error redirectError{&out}; CompressedImage2D{CompressedPixelFormat::Bc2RGBAUnorm, {4, 4}, Containers::Array{2}}; - CORRADE_COMPARE(out.str(), "CompressedImage::CompressedImage(): data too small, got 2 but expected at least 4 bytes\n"); + CORRADE_COMPARE(out.str(), "CompressedImage: data too small, got 2 but expected at least 4 bytes\n"); /* Size should be rounded up even if the image size is not full block */ } { std::ostringstream out; Error redirectError{&out}; CompressedImage2D{CompressedPixelFormat::Bc2RGBAUnorm, {2, 2}, Containers::Array{2}}; - CORRADE_COMPARE(out.str(), "CompressedImage::CompressedImage(): data too small, got 2 but expected at least 4 bytes\n"); + CORRADE_COMPARE(out.str(), "CompressedImage: data too small, got 2 but expected at least 4 bytes\n"); } } diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index 24c910d18..597e433cf 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -604,7 +604,7 @@ void ImageViewTest::constructNullptr() { std::ostringstream out; Error redirectError{&out}; ImageView2D{PixelFormat::RGB8Unorm, {1, 3}, nullptr}; - CORRADE_COMPARE(out.str(), "ImageView::ImageView(): data too small, got 0 but expected at least 12 bytes\n"); + CORRADE_COMPARE(out.str(), "ImageView: data too small, got 0 but expected at least 12 bytes\n"); } void ImageViewTest::constructInvalidSize() { @@ -614,7 +614,7 @@ void ImageViewTest::constructInvalidSize() { /* Doesn't consider alignment */ const char data[3*3]{}; ImageView2D{PixelFormat::RGB8Unorm, {1, 3}, data}; - CORRADE_COMPARE(out.str(), "ImageView::ImageView(): data too small, got 9 but expected at least 12 bytes\n"); + CORRADE_COMPARE(out.str(), "ImageView: data too small, got 9 but expected at least 12 bytes\n"); } void ImageViewTest::constructCompressedInvalidSize() { @@ -627,14 +627,14 @@ void ImageViewTest::constructCompressedInvalidSize() { std::ostringstream out; Error redirectError{&out}; CompressedImageView2D{CompressedPixelFormat::Bc2RGBAUnorm, {4, 4}, data}; - CORRADE_COMPARE(out.str(), "CompressedImageView::CompressedImageView(): data too small, got 2 but expected at least 4 bytes\n"); + CORRADE_COMPARE(out.str(), "CompressedImageView: data too small, got 2 but expected at least 4 bytes\n"); /* Size should be rounded up even if the image size is not full block */ } { std::ostringstream out; Error redirectError{&out}; CompressedImageView2D{CompressedPixelFormat::Bc2RGBAUnorm, {2, 2}, data}; - CORRADE_COMPARE(out.str(), "CompressedImageView::CompressedImageView(): data too small, got 2 but expected at least 4 bytes\n"); + CORRADE_COMPARE(out.str(), "CompressedImageView: data too small, got 2 but expected at least 4 bytes\n"); } } diff --git a/src/Magnum/Trade/ImageData.cpp b/src/Magnum/Trade/ImageData.cpp index d06969324..b390fd357 100644 --- a/src/Magnum/Trade/ImageData.cpp +++ b/src/Magnum/Trade/ImageData.cpp @@ -38,7 +38,7 @@ template ImageData::ImageData(const PixelSto template ImageData::ImageData(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, pixelFormatWrap(format), formatExtra, pixelSize, size, std::move(data), importerState} {} template ImageData::ImageData(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: _compressed{false}, _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _size{size}, _data{std::move(data)}, _importerState{importerState} { - CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "Trade::ImageData::ImageData(): data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); + CORRADE_ASSERT(Magnum::Implementation::imageDataSize(*this) <= _data.size(), "Trade::ImageData: data too small, got" << _data.size() << "but expected at least" << Magnum::Implementation::imageDataSize(*this) << "bytes", ); } template ImageData::ImageData(const CompressedPixelStorage storage, const CompressedPixelFormat format, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: _compressed{true}, _compressedStorage{storage}, _compressedFormat{format}, _size{size}, _data{std::move(data)}, _importerState{importerState} {} diff --git a/src/Magnum/Trade/Test/ImageDataTest.cpp b/src/Magnum/Trade/Test/ImageDataTest.cpp index 28564d6d0..0248a63e4 100644 --- a/src/Magnum/Trade/Test/ImageDataTest.cpp +++ b/src/Magnum/Trade/Test/ImageDataTest.cpp @@ -302,7 +302,7 @@ void ImageDataTest::constructInvalidSize() { /* Doesn't consider alignment */ ImageData2D{PixelFormat::RGB8Unorm, {1, 3}, Containers::Array{3*3}}; - CORRADE_COMPARE(out.str(), "Trade::ImageData::ImageData(): data too small, got 9 but expected at least 12 bytes\n"); + CORRADE_COMPARE(out.str(), "Trade::ImageData: data too small, got 9 but expected at least 12 bytes\n"); } void ImageDataTest::constructCompressedInvalidSize() {