Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
0c726a3f
Commit
0c726a3f
authored
Jun 19, 2013
by
hbristow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved exception handling and unit tests
parent
bbece095
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
2 deletions
+46
-2
template_class_base.cpp
modules/matlab/generator/templates/template_class_base.cpp
+10
-0
template_function_base.cpp
...les/matlab/generator/templates/template_function_base.cpp
+4
-1
OpenCVTest.m
modules/matlab/test/OpenCVTest.m
+29
-1
testsuite.m
modules/matlab/test/testsuite.m
+3
-0
No files found.
modules/matlab/generator/templates/template_class_base.cpp
View file @
0c726a3f
...
...
@@ -27,6 +27,16 @@ std::vector<Bridge> {{function.name}}({{clss.name}}& inst, const std::vector<Bri
// setup
// invoke
try
{
// invoke
}
catch
(
cv
::
Exception
&
e
)
{
mexErrMsgTxt
(
std
::
string
(
"cv::exception caught: "
).
append
(
e
.
what
()).
c_str
());
}
catch
(
std
::
exception
&
e
)
{
mexErrMsgTxt
(
std
::
string
(
"std::exception caught: "
).
append
(
e
.
what
()).
c_str
());
}
catch
(...)
{
mexErrMsgTxt
(
"Uncaught exception occurred in {{fun.name}}"
);
}
// setdown
}
...
...
modules/matlab/generator/templates/template_function_base.cpp
View file @
0c726a3f
...
...
@@ -11,6 +11,7 @@
#include "bridge.hpp"
#include <string>
#include <vector>
#include <exception>
#include <opencv2/core.hpp>
{
%
block
includes
%
}
{
%
endblock
%
}
...
...
@@ -42,7 +43,9 @@ void mexFunction(int nlhs, mxArray* plhs[],
try
{
{{
fun
.
name
}}();
}
catch
(
cv
::
Exception
&
e
)
{
mexErrMsgTxt
(
std
::
string
(
"OpenCV exception caught: "
).
append
(
e
.
what
()).
c_str
());
mexErrMsgTxt
(
std
::
string
(
"cv::exception caught: "
).
append
(
e
.
what
()).
c_str
());
}
catch
(
std
::
exception
&
e
)
{
mexErrMsgTxt
(
std
::
string
(
"std::exception caught: "
).
append
(
e
.
what
()).
c_str
());
}
catch
(...)
{
mexErrMsgTxt
(
"Uncaught exception occurred in {{fun.name}}"
);
}
...
...
modules/matlab/test/OpenCVTest.m
View file @
0c726a3f
...
...
@@ -5,7 +5,7 @@ classdef OpenCVTest < matlab.unittest.TestCase
methods
(
Test
)
% check if the autogenerated functions can be found
function
randExists
(
testcase
)
function
functionsExist
(
testcase
)
try
cv
.
rand
();
catch
...
...
@@ -13,5 +13,33 @@ classdef OpenCVTest < matlab.unittest.TestCase
end
testcase
.
verifyTrue
(
true
);
end
% check that std exception is thrown
function
stdException
(
testcase
)
try
std_exception
();
testcase
.
verifyFail
();
catch
% TODO: Catch more specific exception
testcase
.
verifyTrue
(
true
);
end
end
% check that OpenCV exceptions are correctly caught
function
cvException
(
testcase
)
testcase
.
verifyFail
();
end
% check that all exceptions are caught
function
allException
(
testcase
)
try
exception
();
testcase
.
verifyFail
();
catch
% TODO: Catch more specific exception
testcase
.
verifyTrue
(
true
);
end
end
end
end
modules/matlab/test/testsuite.m
View file @
0c726a3f
...
...
@@ -3,3 +3,6 @@ opencv_tests = OpenCVTest();
%run the tests
result
=
run
(
opencv_tests
);
% shutdown
exit
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment