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");