test addOverload

release/4.3a0
dellaert 2014-11-12 22:06:53 +01:00
parent b7da52a61b
commit ad9f3b334c
3 changed files with 34 additions and 3 deletions

View File

@ -31,6 +31,12 @@ using namespace wrap;
/* ************************************************************************* */
void Method::addOverload(bool verbose, bool is_const, const std::string& name,
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->is_const_ = is_const;
this->name = name;

View File

@ -34,6 +34,11 @@ struct ReturnType: Qualified {
isPtr(false), category(CLASS) {
}
ReturnType(const std::string& name) :
isPtr(false), category(CLASS) {
Qualified::name = name;
}
void rename(const Qualified& q) {
name = q.name;
namespaces = q.namespaces;
@ -75,6 +80,11 @@ struct ReturnValue {
isPair(false) {
}
/// Constructor
ReturnValue(const ReturnType& type) :
isPair(false), type1(type) {
}
std::string return_type(bool add_ptr) const;
std::string matlab_returnType() const;

View File

@ -17,19 +17,34 @@
**/
#include <wrap/Method.h>
#include <CppUnitLite/TestHarness.h>
#include <iostream>
using namespace std;
using namespace wrap;
/* ************************************************************************* */
// Constructor
TEST( Method, Constructor ) {
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);
}
/* ************************************************************************* */