In creating a shared library, I must implement the function void foo(); foo() has dependencies that I would like to mock in my unit tests. My initial thought is to rewrite the signature to include default parameters so that I can inject the dependencies.
One option is to use foo() as a wrapper around bar() and write unit tests for bar() like so:
void bar(SomeClass *someObject=NULL); // test this
void foo() {
bar();
}
However, my question is how safe is it to modify foo() to take default parameters without breaking the library import or usage of foo()?
I can do things with the processor to rewrite the signature depending on build settings(test, debug, release); however, the question still remains. I can't recall how C++ implements default parameters under the hood.
Aucun commentaire:
Enregistrer un commentaire