Unit Test Statically Typed Programs

4 points by 16s ↗ HN
I've helped some younger guys (who use Python and Ruby almost exclusively) write some C++ code. They do lots of unit testing on their Ruby/Python code. They complain that I don't unit test C++.

My C++ code is small and works as expected. It's compiled with all the compiler checks enabled (-Wall -Wextra -Weffc++) so any slight error is caught and fixed at compile time. I don't do any casting and I use a const wherever I can and all the data structures are STL.

So my question to HN... do you guys unit check C and C++ code? In my mind, the compiler (written by a lot of super smart guys) is my unit tester and the only reason the young guys need to do this sort of thing is because they're using dynamically typed (thus more error prone) languages.

I wanted to do a sanity check with HN though. What do you guys think?

3 comments

[ 3.5 ms ] story [ 17.3 ms ] thread
int gimme42() { return 41; }

"all the compiler checks enabled"

Unit testing is a good idea in any language. If you look at their tests, I doubt many of them look like type checks. I bet most of them are logic tests. The compiler would not negate the usefulness of such tests.