News for hackers. Stuff that matters.
Re:Testing code is simple by linuxlizard on Thursday September 26, 2013 @09:45AM (#6450644)
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?

Re:Testing code is simple by TorKlingberg on Thursday September 26, 2013 @11:20AM (#6451364)
A 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.