[Cppunit-devel] Subclassing Exception class for better test failure report
Brought to you by:
blep
From: Baptiste L. <bl...@cl...> - 2001-06-10 11:59:56
|
I want to allow library users and cppunit to subclass the Exception class. First purpose for this would be to have a NotEqualException which would take two strings in the constructor (acual and expected), allowing better error report (put the text on different line, on different edit filed in a GUI...). Further purpose is to allow users of the library to "create" their one assertions and capture more information, while still being able to use cppunit framework. To do this we need: - be able to duplicate any instance of Exception (or subclassed Exception) - identify the actual Exception type so we can downcast if allow. To do this, I propose to: - add "public virtual Exception *clone() const" method which returns a copy of the Exception. - add "protected virtual std::string exceptionType() const" method which returns a string that identify the exception type (the most extensible and portable way I can think of). - add "public static bool isInstanceOf( Exception &e )" method to each class which inherits Exception. This method returns true if exceptionType() return the correct identifier string. I'd like to be able to report assertEqual() in a better way soon, so feedback is welcome. A simple string work well for simple data, but when you are comparing data structure, it's unreadable. Thanks, Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). |