From 0f7f2e0780a6286f49f20f2c591bf7281101037e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 7 Sep 2015 22:44:57 +0200 Subject: [PATCH] Verify that it's possible to create ImageView with nullptr data. For example for old-style texture allocation using setImage(). Asserts now. --- src/Magnum/Test/ImageViewTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index 55477ec83..4ef3cffd2 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -34,6 +34,7 @@ struct ImageViewTest: TestSuite::Tester { explicit ImageViewTest(); void construct(); + void constructNullptr(); void constructCompressed(); void setData(); @@ -42,6 +43,7 @@ struct ImageViewTest: TestSuite::Tester { ImageViewTest::ImageViewTest() { addTests({&ImageViewTest::construct, + &ImageViewTest::constructNullptr, &ImageViewTest::constructCompressed, &ImageViewTest::setData, @@ -60,6 +62,13 @@ void ImageViewTest::construct() { CORRADE_COMPARE(a.data(), data); } +void ImageViewTest::constructNullptr() { + /* Just verify that it won't assert when passing nullptr array -- useful + e.g. for old-style texture allocation using setImage() */ + ImageView2D a{PixelFormat::RGBA, PixelType::UnsignedByte, {256, 128}, nullptr}; + CORRADE_COMPARE(a.size(), (Vector2i{256, 128})); +} + void ImageViewTest::constructCompressed() { const char data[8]{}; CompressedImageView2D a{