From 55b90d7bae8eea2899828f324aeb30d1e7005c6f Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Thu, 31 Jan 2013 18:17:29 +0400 Subject: [PATCH] Modify decode_tile16384x16384 test to not fail when available memory is not enough for test --- modules/highgui/test/test_grfmt.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index c408d89a4d..8366fcdffc 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -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 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