4 ms·
One thing, run your code through debugger after successful compilation with warnings set as errors. If your code does not compile when the warnings are set as e
by TMK 15y ago
One thing, run your code through debugger after successful compilation with warnings set as errors. If your code does not compile when the warnings are set as errors, then fix them. Afterwards run your code in a debugger. Do this as often as you can.
Unit testing is checking that function returns the correct data in different scenarios. This can be easily done with unit testing functions for your language.
For example C preprocessor macros I use for unit testing.
#define equal(a,b) printf("%X == %X = %s\n", a, b, (a == b) ? "true" : "false");
#define diff(a,b) printf("%X != %X = %s\n", a, b, (a != b) ? "true" : "false");
- swordswinger12 15y agoI don't know if preprocessor macros are the best way to unit test C. There are fully featured (and free) unit testing suites out there for c/c++, Boost comes immediately to mind. No need to re-invent the wheel, especially not when there is customer money on the line.