43 #ifndef _DWMUNITASSERT_HH_ 44 #define _DWMUNITASSERT_HH_ 113 Assertion(
const std::string & filename,
const std::string &
function,
114 int line,
const std::string & expression);
119 const std::string & Filename();
124 const std::string & Function();
134 const std::string & Expression()
const;
139 bool operator < (
const Assertion & assertion)
const;
144 friend std::ostream &
148 std::string _filename;
149 std::string _function;
151 std::string _expression;
164 void Failed(
const std::string & filename,
const std::string &
function,
165 int lineNumber,
const std::string & test);
170 void Passed(
const std::string & filename,
const std::string &
function,
171 int lineNumber,
const std::string & test);
181 std::ostream & Print(std::ostream & os,
bool onlyFailed =
false)
const;
183 std::ostream & PrintXML(std::ostream & os,
bool onlyFailed =
false)
const;
186 std::string _function;
187 std::map<Assertion,AssertionCounter> _assertions;
200 void Failed(
const std::string & filename,
const std::string &
function,
201 int lineNumber,
const std::string & test);
206 void Passed(
const std::string & filename,
const std::string &
function,
207 int lineNumber,
const std::string & test);
217 std::ostream & Print(std::ostream & os,
bool onlyFailed =
false)
const;
222 std::ostream & PrintXML(std::ostream & os,
bool onlyFailed =
false)
const;
225 std::string _filename;
226 std::map<std::string,FunctionAssertions> _assertions;
239 static bool Failed(
const std::string & filename,
240 const std::string &
function,
241 int lineNumber,
const std::string & test);
247 static bool Passed(
const std::string & filename,
248 const std::string &
function,
249 int lineNumber,
const std::string & test);
260 static std::ostream & Print(std::ostream & os,
bool onlyFailed =
false);
265 static std::ostream & PrintXML(std::ostream & os,
bool onlyFailed =
false);
268 static std::map<std::string,FileAssertions> _assertions;
269 static std::mutex _mutex;
277 #define UnitAssert(e) ((e) ? \ 278 Dwm::Assertions::Passed(__FILE__, __PRETTY_FUNCTION__, __LINE__, #e) : \ 279 Dwm::Assertions::Failed(__FILE__, __PRETTY_FUNCTION__, __LINE__, #e)) 283 #endif // _DWMUNITASSERT_HH_ void AddPassed()
Increments the passed counter.
A container to hold all assertions. Note everything is static here.
Definition: DwmUnitAssert.hh:232
uint64_t Passed() const
Returns the passed counter.
friend std::ostream & operator<<(std::ostream &os, const AssertionCounter &assertionCounter)
Prints to an ostream.
Definition: DwmBZ2IO.hh:67
void AddFailed()
Increments the failed counter.
A container class to hold all assertions called from a single source file.
Definition: DwmUnitAssert.hh:194
Holds assertion information.
Definition: DwmUnitAssert.hh:107
AssertionCounter()
Constructor.
uint64_t Failed() const
Returns the failed counter.
A container class to hold all assertions called from a single function.
Definition: DwmUnitAssert.hh:158
AssertionCounter & operator+=(const AssertionCounter &assertionCounter)
operator +=
Holds 'passed' and 'failed' counters.
Definition: DwmUnitAssert.hh:60