test addOverload
parent
b7da52a61b
commit
ad9f3b334c
|
@ -31,6 +31,12 @@ using namespace wrap;
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Method::addOverload(bool verbose, bool is_const, const std::string& name,
|
void Method::addOverload(bool verbose, bool is_const, const std::string& name,
|
||||||
const ArgumentList& args, const ReturnValue& retVal) {
|
const ArgumentList& args, const ReturnValue& retVal) {
|
||||||
|
if (name.empty())
|
||||||
|
this->name = name;
|
||||||
|
else if (this->name != name)
|
||||||
|
throw std::runtime_error(
|
||||||
|
"Method::addOverload: tried to add overload with name " + name
|
||||||
|
+ " instead of expected " + this->name);
|
||||||
this->verbose_ = verbose;
|
this->verbose_ = verbose;
|
||||||
this->is_const_ = is_const;
|
this->is_const_ = is_const;
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
|
|
@ -34,6 +34,11 @@ struct ReturnType: Qualified {
|
||||||
isPtr(false), category(CLASS) {
|
isPtr(false), category(CLASS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnType(const std::string& name) :
|
||||||
|
isPtr(false), category(CLASS) {
|
||||||
|
Qualified::name = name;
|
||||||
|
}
|
||||||
|
|
||||||
void rename(const Qualified& q) {
|
void rename(const Qualified& q) {
|
||||||
name = q.name;
|
name = q.name;
|
||||||
namespaces = q.namespaces;
|
namespaces = q.namespaces;
|
||||||
|
@ -75,6 +80,11 @@ struct ReturnValue {
|
||||||
isPair(false) {
|
isPair(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
ReturnValue(const ReturnType& type) :
|
||||||
|
isPair(false), type1(type) {
|
||||||
|
}
|
||||||
|
|
||||||
std::string return_type(bool add_ptr) const;
|
std::string return_type(bool add_ptr) const;
|
||||||
|
|
||||||
std::string matlab_returnType() const;
|
std::string matlab_returnType() const;
|
||||||
|
|
|
@ -17,19 +17,34 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <wrap/Method.h>
|
#include <wrap/Method.h>
|
||||||
|
|
||||||
#include <CppUnitLite/TestHarness.h>
|
#include <CppUnitLite/TestHarness.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace wrap;
|
using namespace wrap;
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
// Constructor
|
||||||
TEST( Method, Constructor ) {
|
TEST( Method, Constructor ) {
|
||||||
Method method;
|
Method method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
|
// addOverload
|
||||||
|
TEST( Method, addOverload ) {
|
||||||
|
Method method;
|
||||||
|
method.name = "myName";
|
||||||
|
bool verbose = true, is_const = true;
|
||||||
|
ArgumentList args;
|
||||||
|
const ReturnValue retVal(ReturnType("return_type"));
|
||||||
|
method.addOverload(verbose, is_const, "myName", args, retVal);
|
||||||
|
EXPECT_LONGS_EQUAL(1,method.argLists.size());
|
||||||
|
EXPECT_LONGS_EQUAL(1,method.returnVals.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
int main() {
|
||||||
|
TestResult tr;
|
||||||
|
return TestRegistry::runAllTests(tr);
|
||||||
|
}
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
Loading…
Reference in New Issue