Added test for overloaded global functions
parent
5e9632e781
commit
399c5e5551
|
@ -502,6 +502,19 @@ void aGlobalFunction_42(int nargout, mxArray *out[], int nargin, const mxArray *
|
|||
checkArguments("aGlobalFunction",nargout,nargin,0);
|
||||
out[0] = wrap< Vector >(aGlobalFunction());
|
||||
}
|
||||
void overloadedGlobalFunction_43(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||
{
|
||||
checkArguments("overloadedGlobalFunction",nargout,nargin,1);
|
||||
int a = unwrap< int >(in[0]);
|
||||
out[0] = wrap< Vector >(overloadedGlobalFunction(a));
|
||||
}
|
||||
void overloadedGlobalFunction_44(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||
{
|
||||
checkArguments("overloadedGlobalFunction",nargout,nargin,2);
|
||||
int a = unwrap< int >(in[0]);
|
||||
double b = unwrap< double >(in[1]);
|
||||
out[0] = wrap< Vector >(overloadedGlobalFunction(a,b));
|
||||
}
|
||||
|
||||
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||
{
|
||||
|
@ -643,6 +656,12 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
|||
case 42:
|
||||
aGlobalFunction_42(nargout, out, nargin-1, in+1);
|
||||
break;
|
||||
case 43:
|
||||
overloadedGlobalFunction_43(nargout, out, nargin-1, in+1);
|
||||
break;
|
||||
case 44:
|
||||
overloadedGlobalFunction_44(nargout, out, nargin-1, in+1);
|
||||
break;
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
function varargout = overloadedGlobalFunction(varargin)
|
||||
if length(varargin) == 1 && isa(varargin{1},'numeric')
|
||||
varargout{1} = geometry_wrapper(43, varargin{:});
|
||||
elseif length(varargin) == 2 && isa(varargin{1},'numeric') && isa(varargin{2},'double')
|
||||
varargout{1} = geometry_wrapper(44, varargin{:});
|
||||
else
|
||||
error('Arguments do not match any overload of function overloadedGlobalFunction');
|
||||
end
|
|
@ -87,6 +87,10 @@ class Test {
|
|||
|
||||
Vector aGlobalFunction();
|
||||
|
||||
// An overloaded global function
|
||||
Vector overloadedGlobalFunction(int a);
|
||||
Vector overloadedGlobalFunction(int a, double b);
|
||||
|
||||
// comments at the end!
|
||||
|
||||
// even more comments at the end!
|
||||
|
|
|
@ -307,8 +307,8 @@ TEST( wrap, parse_geometry ) {
|
|||
}
|
||||
|
||||
// evaluate global functions
|
||||
// Vector aGlobalFunction();
|
||||
LONGS_EQUAL(1, module.global_functions.size());
|
||||
// Vector aGlobalFunction();
|
||||
LONGS_EQUAL(2, module.global_functions.size());
|
||||
CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end());
|
||||
{
|
||||
GlobalFunction gfunc = module.global_functions.at("aGlobalFunction");
|
||||
|
@ -447,6 +447,7 @@ TEST( wrap, matlab_code_geometry ) {
|
|||
EXPECT(files_equal(epath + "Point3.m" , apath + "Point3.m" ));
|
||||
EXPECT(files_equal(epath + "Test.m" , apath + "Test.m" ));
|
||||
EXPECT(files_equal(epath + "aGlobalFunction.m" , apath + "aGlobalFunction.m" ));
|
||||
EXPECT(files_equal(epath + "overloadedGlobalFunction.m" , apath + "overloadedGlobalFunction.m" ));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
Loading…
Reference in New Issue