Re: Dos and don'ts in C++ unit testing?
On 13 Feb., 20:54, "Daniel T." <danie...@earthlink.net> wrote:
If so, then the advice you read about C# and Java generally also works
with C++ though a few extra things need to be done in the C++ case. We
have to also make sure that values are initialized with reasonable
defaults and make sure that dynamically allocated memory is returned to
the system.
Actually the same two points apply to C# and Java as well. The fact
that
both languages define *predictable* initial values of class members
doesn't mean that these are correct ones, that is, that those values
would
auto*magically* fulfill the corresponding class constraints.
Another point is, that you cannot provide a userdefined default c'tor
for
C#'s ValueType's, so you have to ensure that such a "zero-
initialization"
creates an instance fulfilling its class constraints - otherwise you
don't
have to forget to call the proper init function or another userdefined
c'tor.
Proper resource management is also relevant for all GC languages: Non-
memory resources are 100% your responsibility and inproper class
design
can also lead to memory "garbadge" that is not freed because of cyclic
dependencies that are not manually resolved (similarily: Proper use
of WeakReferences).
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]