diff --git a/wrap/Method.cpp b/wrap/Method.cpp index 2751135dd..28cdbfe52 100644 --- a/wrap/Method.cpp +++ b/wrap/Method.cpp @@ -31,16 +31,14 @@ using namespace wrap; /* ************************************************************************* */ void Method::addOverload(bool verbose, bool is_const, const std::string& name, const ArgumentList& args, const ReturnValue& retVal) { -#ifdef ADD_OVERLOAD_CHECK_NAME - if (!name.empty() && this->name != name) + if (!this->name.empty() && this->name != name) throw std::runtime_error( "Method::addOverload: tried to add overload with name " + name + " instead of expected " + this->name); -#endif - this->name = name; + else + this->name = name; this->verbose_ = verbose; this->is_const_ = is_const; - this->name = name; this->argLists.push_back(args); this->returnVals.push_back(retVal); } diff --git a/wrap/tests/testClass.cpp b/wrap/tests/testClass.cpp index 627f3a9ff..5ab0e00b8 100644 --- a/wrap/tests/testClass.cpp +++ b/wrap/tests/testClass.cpp @@ -33,14 +33,25 @@ TEST( Class, Constructor ) { // addMethodOverloads TEST( Class, addMethod ) { Class cls; + const string name = "method1"; + EXPECT(!cls.exists(name)); + bool verbose=true, is_const=true; - const string name; ArgumentList args; const ReturnValue retVal; const string templateArgName; vector templateArgValues; cls.addMethod(verbose, is_const, name, args, retVal, templateArgName, templateArgValues); + EXPECT_LONGS_EQUAL(1,cls.nrMethods()); + EXPECT(cls.exists(name)); + Method& method = cls.method(name); + EXPECT_LONGS_EQUAL(1,method.returnVals.size()); + + cls.addMethod(verbose, is_const, name, args, retVal, templateArgName, + templateArgValues); + EXPECT_LONGS_EQUAL(1,cls.nrMethods()); + EXPECT_LONGS_EQUAL(2,method.returnVals.size()); } /* ************************************************************************* */