1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

VideoCapture: add exception error mode similar to fstream + test

This commit is contained in:
Pavel Rojtberg
2018-06-12 15:21:33 +02:00
parent 64168fc20a
commit 15bb0b86ce
3 changed files with 59 additions and 7 deletions
+19
View File
@@ -416,4 +416,23 @@ INSTANTIATE_TEST_CASE_P(videoio, videoio_synthetic,
testing::ValuesIn(all_sizes),
testing::ValuesIn(synthetic_params)));
TEST(Videoio, exceptions)
{
VideoCapture cap;
Mat mat;
EXPECT_FALSE(cap.grab());
EXPECT_FALSE(cap.retrieve(mat));
EXPECT_FALSE(cap.set(CAP_PROP_POS_FRAMES, 1));
EXPECT_FALSE(cap.open("this_does_not_exist.avi", CAP_OPENCV_MJPEG));
cap.setExceptionMode(true);
EXPECT_THROW(cap.grab(), Exception);
EXPECT_THROW(cap.retrieve(mat), Exception);
EXPECT_THROW(cap.set(CAP_PROP_POS_FRAMES, 1), Exception);
EXPECT_THROW(cap.open("this_does_not_exist.avi", CAP_OPENCV_MJPEG), Exception);
}
} // namespace