6 ms·
May I also suggest an extended assert? xassert(condition,value); e.g., xassert(result==3,result); When the assert fails, the value is also reported. Helps wi
by linuxlizard 13y ago
May I also suggest an extended assert?
xassert(condition,value);
e.g., xassert(result==3,result);
When the assert fails, the value is also reported. Helps with the question, "So it's not 3. What is it?"
I started using xassert when working in embedded systems where there is no debugger, no stack trace. Knowing the value of the error is valuable.
retcode = some_os_function(blah,blah,blah);
xassert(retcode==OS_SUCCESS,retcode); <--- why did my call fail?
- TorKlingberg 13y agoA common version is to have assertEquals(a, b), that will print out both a and b if they are not equal. Then add similar asserts for "not equal", "less than" and other relations.