Modify decode_tile16384x16384 test to not fail when available memory is not enough...
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Thu, 31 Jan 2013 14:17:29 +0000 (18:17 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Thu, 31 Jan 2013 14:51:24 +0000 (18:51 +0400)
modules/highgui/test/test_grfmt.cpp

index c408d89..8366fcd 100644 (file)
@@ -304,14 +304,27 @@ TEST(Highgui_Tiff, decode_tile16384x16384)
 {
     // see issue #2161
     cv::Mat big(16384, 16384, CV_8UC1, cv::Scalar::all(0));
-    string file = cv::tempfile(".tiff");
+    string file3 = cv::tempfile(".tiff");
+    string file4 = cv::tempfile(".tiff");
+
     std::vector<int> params;
     params.push_back(TIFFTAG_ROWSPERSTRIP);
     params.push_back(big.rows);
-    cv::imwrite(file, big, params);
+    cv::imwrite(file4, big, params);
+    cv::imwrite(file3, big.colRange(0, big.cols - 1), params);
     big.release();
 
-    EXPECT_NO_THROW(cv::imread(file));
-    remove(file.c_str());
+    try
+    {
+        cv::imread(file3);
+        EXPECT_NO_THROW(cv::imread(file4));
+    }
+    catch(const std::bad_alloc&)
+    {
+        // have no enough memory
+    }
+
+    remove(file3.c_str());
+    remove(file4.c_str());
 }
 #endif