From fb8e8f3d56342eeafcea3629ad8d24832578d51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 12 Sep 2016 10:29:42 +0200 Subject: [PATCH] Test that passing any Array(View) to ImageView works on deprecated build. It fails to compile with ambiguous overloads. Shouldn't be this way. --- src/Magnum/Test/ImageViewTest.cpp | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index 45c8cf8df..18e300d3b 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -36,8 +36,16 @@ struct ImageViewTest: TestSuite::Tester { void construct(); void constructNullptr(); void constructCompressed(); + #ifdef MAGNUM_BUILD_DEPRECATED + void constructDeprecatedArrayView(); + void constructDeprecatedArray(); + #endif void setData(); + #ifdef MAGNUM_BUILD_DEPRECATED + void setDataDeprecatedArrayView(); + void setDataDeprecatedArray(); + #endif void setDataCompressed(); }; @@ -45,8 +53,16 @@ ImageViewTest::ImageViewTest() { addTests({&ImageViewTest::construct, &ImageViewTest::constructNullptr, &ImageViewTest::constructCompressed, + #ifdef MAGNUM_BUILD_DEPRECATED + &ImageViewTest::constructDeprecatedArrayView, + &ImageViewTest::constructDeprecatedArray, + #endif &ImageViewTest::setData, + #ifdef MAGNUM_BUILD_DEPRECATED + &ImageViewTest::setDataDeprecatedArrayView, + &ImageViewTest::setDataDeprecatedArray, + #endif &ImageViewTest::setDataCompressed}); } @@ -85,6 +101,23 @@ void ImageViewTest::constructCompressed() { CORRADE_COMPARE(a.data(), data); } +#ifdef MAGNUM_BUILD_DEPRECATED +void ImageViewTest::constructDeprecatedArrayView() { + const char data[12]{}; + Containers::ArrayView view{data}; + ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, view}; + + CORRADE_COMPARE(a.data(), data); +} + +void ImageViewTest::constructDeprecatedArray() { + Containers::Array data{12}; + ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, data}; + + CORRADE_COMPARE(a.data(), data); +} +#endif + void ImageViewTest::setData() { const char data[3*3]{}; ImageView2D a{PixelStorage{}.setAlignment(1), @@ -99,6 +132,25 @@ void ImageViewTest::setData() { CORRADE_COMPARE(a.data(), data2); } +#ifdef MAGNUM_BUILD_DEPRECATED +void ImageViewTest::setDataDeprecatedArrayView() { + ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, nullptr}; + + const char data[12]{}; + Containers::ArrayView view{data}; + a.setData(view); + CORRADE_COMPARE(a.data(), data); +} + +void ImageViewTest::setDataDeprecatedArray() { + ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, nullptr}; + + Containers::Array data{12}; + a.setData(data); + CORRADE_COMPARE(a.data(), data); +} +#endif + void ImageViewTest::setDataCompressed() { const char data[8]{}; CompressedImageView2D a{