[cartwheel] Testing C/C++ Code.

Diane Trout diane at caltech.edu
Wed Feb 28 12:10:54 PST 2007


I wanted to check with everyone about testing C/C++ code. I've used 4
different methods, each with their own trade offs, and wanted to see if
there was a chance we could adopt a common set of C/C++ testing tools.

Boost Test
----------

http://www.boost.org/libs/test/doc/components/utf/index.html

Currently in Mussa I'm using Boost Unit Test for validing most of the
algorithmic portions.

Boost Test is exceptionally good at reporting what went wrong in your
test. For instance if a test segfaults or tosses an unexected exception,
Boost Test can catch and report the problem, and then continue running
the rest of your testsl

On the downside, boost is big and they're using their own build system
so it can be something of a pain to build under os x or windows. (Most
Linux distributions ship precompiled versions) (On the other upside
there's a lot of really useful things in boost) (at least 10 of of the
~67 libraries are likely to be in the next version of C++)

Qt Test
-------

http://doc.trolltech.com/4.2/qtestlib-manual.html

I have less experience with Qt4's testing abilities. It does look
complete, and is one of the few that can test GUI components (which is
where mussa is currently using it).

However I didn't want to depend completely on Qt4 test because I wanted
to keep the core algorithmic portion of Mussa GUI toolkit independent.

Python Testing
--------------

Another solution would just be to wrap everything with a C/Python
binding and run all the tests from python. The only advantage to this is
we'd get all the unit test reports in once place. It's likely to be far
more fragile, and is also would  to break when a Python 3000 comes out.

Handcoded Tests
---------------

Cartwheel's current C++ tests are just C++ programs that call assert
statements. This is quite simple and requires no supporting libraries.
Of course you need to run the program in a debugger to get any idea of
where something went wrong.

Conclusion
----------

I like boost, I just am not sure how much of a pain it is for other
people to install. Qt4 is also a good choice for testing (and
development). Qt4 is really easy to install on windows, OS X, and Linux.
(Qt4 is so easy to install on windows that it's one of the best ways of
setting up an open source windows development environment).


However boost has a far more liberal license than Qt, and can be used
with any graphics toolkit (including no graphics toolkit). Not to
mention several chunks of boost are going to become standard C++.


Diane

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://lists.idyll.org/pipermail/cartwheel/attachments/20070228/ed9ded04/attachment.pgp 


More information about the cartwheel mailing list