What we do in our code? ◦ Essentially it will do following Some mathematical calculation based on data we have. Data manipulation/ memory manipulation. On Stack On Heap. Conditions Execution path
◦ Output of such logic must me tested w.r.t. all possible conditions (best case, worst cases and boundary cases) Data Manipulation ◦ On Stack Correct usage of stack Conditions of stack overflow. Passing address of stack allocated memory to such function, which are out of scope of functions stack.
under-run/over-run issues. Uninitialized memory access/manipulation. Execution paths ◦ A function can have various execution paths depending on if-else, switch, goto usage in code. ◦ All execution paths must be executed at-least once with all possible conditions. ◦ Terminating condition for loops.
of prints ◦ Usage of Asserts – defensing programming. Methods to debug newly added function(s). ◦ In, Out parameters and return values. ◦ ASSERT for mandatory parameters for expected value or range. (used for debug version only) ◦ Handle the graceful exit from function with proper error return value (wherever applicable) ◦ Defined return path and value.
◦ If coping data to some memory location, check for size of copy and start address of storage. ( Buffer over-run / under-run conditions). ◦ Global structure management - use of reference count. ◦ Memory corruptions Padding – add some signature at start and end of memory allocated while allocation, and check while freeing it.
case and boundary cases. ◦ Invoke functions/Macros from test code and verify if it works as expected in all scenarios. Modification in current code. ◦ Verify for all modifications, if they are not breaking or introducing new bug to existing function.