Skip to content

Commit

Permalink
more exception handling test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Feb 23, 2022
1 parent 74f599a commit baf7053
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions test/test_overloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,39 @@ class ConfigFileNotFoundError : public std::exception {
const char* what() const throw() { return fMsg.c_str(); }
};
class MyClass {
class MyClass1 {
public:
MyClass(const std::string& configfilename) {
MyClass1(const std::string& configfilename) {
throw ConfigFileNotFoundError{configfilename};
}
MyClass(const MyClass& other) {}
}; }""")
MyClass1(const MyClass1& other) {}
};
class MyClass2 {
public:
MyClass2(const std::string& configfilename) {
throw ConfigFileNotFoundError{configfilename};
}
MyClass2(const char* configfilename) {
throw ConfigFileNotFoundError{configfilename};
}
MyClass2(const MyClass2& other) {}
};
class MyClass3 {
public:
MyClass3(int) {}
MyClass3(const MyClass3& other) {}
}; }""")

ns = cppyy.gbl.ExceptionTypeTest

with raises(ns.ConfigFileNotFoundError):
ns.MyClass("some_file")
ns.MyClass1("some_file")

with raises(TypeError):
ns.MyClass2("some_file")

with raises(TypeError):
ns.MyClass3("some_file")

0 comments on commit baf7053

Please sign in to comment.