Added more test cases
This commit is contained in:
@@ -153,7 +153,7 @@ add_custom_command(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_matlab.py ${HDR_PARSER_PATH}
|
${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_matlab.py ${HDR_PARSER_PATH}
|
||||||
${opencv_hdrs} ${CMAKE_CURRENT_BINARY_DIR}
|
${opencv_hdrs} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${GENERATE_PROXY}
|
COMMAND ${CMAKE_COMMAND} -E touch ${GENERATE_PROXY}
|
||||||
COMMENT "Generating matlab source files"
|
COMMENT "Generating Matlab source files"
|
||||||
)
|
)
|
||||||
|
|
||||||
# compile
|
# compile
|
||||||
|
@@ -1,25 +1,20 @@
|
|||||||
# compile the test sources
|
set(TEST_PROXY ${CMAKE_CURRENT_BINARY_DIR}/test.proxy)
|
||||||
file(GLOB SOURCE_FILES "*.cpp")
|
file(REMOVE ${TEST_PROXY})
|
||||||
add_custom_target(opencv_test_matlab_sources)
|
|
||||||
foreach(SOURCE_FILE ${SOURCE_FILES})
|
|
||||||
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
|
|
||||||
# compile the source file using mex
|
|
||||||
add_custom_command(TARGET opencv_test_matlab_sources PRE_BUILD
|
|
||||||
COMMAND echo ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES}
|
|
||||||
${SOURCE_FILE}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# copy the test files into the build dir
|
# generate
|
||||||
file(GLOB TEST_FILES "*.m")
|
# call the python executable to generate the Matlab gateways
|
||||||
foreach(TEST_FILE ${TEST_FILES})
|
add_custom_command(
|
||||||
add_custom_command(TARGET opencv_test_matlab_sources PRE_BUILD
|
OUTPUT ${TEST_PROXY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/OpenCVTest.m ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
copy ${TEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testsuite.m ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
COMMAND ${CMAKE_COMMAND} -E touch ${TEST_PROXY}
|
||||||
endforeach()
|
COMMENT "Building Matlab tests"
|
||||||
|
)
|
||||||
|
|
||||||
|
# targets
|
||||||
|
# opencv_matlab_sources --> opencv_matlab
|
||||||
|
add_custom_target(opencv_test_matlab ALL DEPENDS ${TEST_PROXY})
|
||||||
|
add_dependencies(opencv_test_matlab ${the_module})
|
||||||
|
|
||||||
# run the matlab test suite
|
# run the matlab test suite
|
||||||
add_test(opencv_test_matlab
|
add_test(opencv_test_matlab
|
||||||
|
@@ -4,16 +4,6 @@ classdef OpenCVTest < matlab.unittest.TestCase
|
|||||||
|
|
||||||
methods(Test)
|
methods(Test)
|
||||||
|
|
||||||
% check if the autogenerated functions can be found
|
|
||||||
function functionsExist(testcase)
|
|
||||||
try
|
|
||||||
cv.rand();
|
|
||||||
catch
|
|
||||||
testcase.verifyFail();
|
|
||||||
end
|
|
||||||
testcase.verifyTrue(true);
|
|
||||||
end
|
|
||||||
|
|
||||||
% check that std exception is thrown
|
% check that std exception is thrown
|
||||||
function stdException(testcase)
|
function stdException(testcase)
|
||||||
try
|
try
|
||||||
@@ -27,7 +17,13 @@ classdef OpenCVTest < matlab.unittest.TestCase
|
|||||||
|
|
||||||
% check that OpenCV exceptions are correctly caught
|
% check that OpenCV exceptions are correctly caught
|
||||||
function cvException(testcase)
|
function cvException(testcase)
|
||||||
testcase.verifyFail();
|
try
|
||||||
|
cv_exception();
|
||||||
|
testcase.verifyFail();
|
||||||
|
catch
|
||||||
|
% TODO: Catch more specific exception
|
||||||
|
testcase.verifyTrue(true);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% check that all exceptions are caught
|
% check that all exceptions are caught
|
||||||
@@ -41,5 +37,21 @@ classdef OpenCVTest < matlab.unittest.TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
% check that a matrix is correctly filled with random numbers
|
||||||
|
function randomFill(testcase)
|
||||||
|
sz = [7 11];
|
||||||
|
mat = zeros(sz);
|
||||||
|
mat = cv.randn(mat, 0, 1);
|
||||||
|
testcase.verifyEqual(size(mat), sz, 'Matrix should not change size');
|
||||||
|
testcase.verifyNotEqual(mat, zeros(sz), 'Matrix should be nonzero');
|
||||||
|
end
|
||||||
|
|
||||||
|
% check that cv::waitKey waits for at least specified time
|
||||||
|
function waitKey(testcase)
|
||||||
|
tic();
|
||||||
|
cv.waitKey(500);
|
||||||
|
elapsed = toc();
|
||||||
|
testcase.verifyGreaterThan(elapsed, 0.5, 'Elapsed time should be at least 0.5 seconds');
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
% add the opencv bindings folder
|
||||||
|
addpath ..
|
||||||
|
|
||||||
%setup the tests
|
%setup the tests
|
||||||
opencv_tests = OpenCVTest();
|
opencv_tests = OpenCVTest();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user