Re: Unit Testing in C++






"Paulo Matos" <pocmatos@xxxxxxxxx> wrote in message
news:1161943505.055829.127480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,

I'm quite curious on how you would go to perform unit testing in C++.
One way is to use one of the 'lot' of libraries available for the
purpose cppunit, c++unit, *unit in general... Other way would be to
tailor your tests manually. I would love to hear about experiences with
these methods and particular libraries. Which one has met your needs or
which one do you suggest.

The class has a public interface that will support various operations.

Therefore you write a unti of test code to instantiate one or more instances
of the class, then call every method.
Ideally the tests will be extensive enough to make sure that every line of
code is executed at least once.

Unfortunately, for a non-trivial class, there is no way to ensure that all
cases have been tested thoroughly. C++ is particularly difficult to test
because classes store state throughout the system. Therefore

mymathobj.sqrt(4);
mymathobj.tan(PI);

might give the right results

mymathobj.tan(PI);
mymathobj.sqrt(4);

might give the wrong result.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.


.



Relevant Pages

  • Re: How to get imagebase after a DLL gets loaded
    ... how can you be unaware of the names of variables in DLL module that you ... Implementing a library that requires users of the library to instantiate ... predict what variable name you will use at initialization time. ... Some third-party libraries DO require that you instantiate a pre-defined ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How to get imagebase after a DLL gets loaded
    ... During the process of building the DLL, ... Implementing a library that requires users of the library to instantiate ... predict what variable name you will use at initialization time. ... Some third-party libraries DO require that you instantiate a pre-defined ...
    (microsoft.public.win32.programmer.kernel)
  • Re: FileNotFoundException
    ... class to instantiate from configuration and uses reflection to perform the ... misread the part about reflection. ... >> Adam Clauss ... >>> It turns out one of the libraries I use instantiates a class using ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: which unit testing library?
    ... Frank Buss wrote: ... I found many unit testing ... frameworks on cliki.net, and I would appreciate some advice on which ... I didn't know the libraries and maybe they are better, ...
    (comp.lang.lisp)
  • global variables in shared libraries
    ... to be included in Debian, I feel that I should not be slaughtered ... I have a question about shared libraries. ... I have come up with two ways to deal without global variables in C: ... The first is to expect the user to instantiate a struct, ...
    (Debian-User)