Instance-specific unittests

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Feb 13 16:32:31 PST 2012


On Mon, Feb 13, 2012 at 07:15:18PM -0500, Steven Schveighoffer wrote:
[...]
> 3. If you are making classes like this, make *sure* all your unit
> test helper functions are non-virtual!  Otherwise, if some code
> instantiates with unit tests on and some off, you will have vtable
> inconsistencies.
[...]

I usually just use version(unittest){...} at the top of the file to make
module-wide unittest helper functions. I don't like modifying the thing
I'm testing just by the act of testing it (e.g., adding class members
when running unittests for that class). This may be a fact of life in
quantum physics, but for testing code I prefer the "independent
observer" mode of operation. :)


T

-- 
Lottery: tax on the stupid. -- Slashdotter


More information about the Digitalmars-d-learn mailing list