mercredi 29 juillet 2015

Strategy to unit test move/copy constructors?

I want to write unit tests to test move/copy constructors/assigments of some classes I am writing. I want to make sure that the resources are handled appropriately, that a move ctor is called when I expect it to be called instead of a copy ctor, and vice-versa.

The problem is that I don't want to mess with the class code in order to test this. So, is there a way to know from the test code outside the class, when the move or the copy ctors/assignments were called?

What's a general strategy to unit-test copy/move ctors/assignments?

PD: I am using Catch unit-testing framework, so please provide an answer that can be implemented in Catch.

Aucun commentaire:

Enregistrer un commentaire