I have tons of run time assertion failure in my application and I need to sit with each one to find out what is the run time value of the assert conditions that results such a failure. For example:
assert ( a == b ) ;
in line number 100 failed. in run time, I can only see that some thing happen in line number 100 then, I need to set a break point there to find out actual value of a and b.
My questions is that is there any way to get more intelligent failure report more than line numbers? I would like to see value of variables that are mismatch.
You can utilize the language to define your own assert macros of course:
However, I would argue that if you’re relying excesively on assertions, you might want to express some of thes “exceptional” errors as exceptions. A good debugger will catch these and describe the exception by name. You may have something more meaningful to say rather than
a != b, for example:While this is useful, its important to realize than exceptions get thrown in both debug and release builds while assertions typically only get run in debug builds.