I'm not sure I get what you're saying. Are you asking if, once an application has been built, you can remove some of the code used to create it at runtime? Because you definately cannot do that. If you want to like, make a class behave differently or something, you might want to look into using dlls and rename a couple of dlls to use different implementation of the same functions, but you would still need to restart the application. If I understand you correctly, you should post specifically what you are trying to accomplish because there has to be a better way of doing it.
Let me tell you what I am trying to accomplish so that it is more clear.
I have a test driver that tests the software (a dll with 3 classes) that I had written. In my test driver, I need to simulate the occurence of a null pointer (a private member attribute that gets set when a particular object is created).
I am not sure how to force the pointer to become null through my test driver. Since the #include of the object's header file is what allows the creation of the object, I was trying to figure out how I can "ignore" the #include statement which would result in the object not being able to be created (hence the null member attribute).
Excluding class information won't allow you to compile. The only way to force something to be NULL is to assign it NULL, \0 or 0. Since this is a private member your trying to force NULL, the only way to do it is to have a bit of code that looks for a test/debug flag and inside the class assigns it NULL.
Perhaps you are over testing something that isn't very important or is very low risk. If I say:
static const int _BLAH_ = 5; It is probably a waste of testing resorces to try and garuntee that the value hasn't changed and that there really is only one of them.
I know, it is kindaa overkill. In the same breath, the creation of this object is important and nothing else will work w/out it so it must be handled appropriately in a error situation.
I have to do it... it is not really my decision.
Rather than writing a test harness to test a condition that is almost impossible to test, you might be better off doing a code review of the area that you are concerned with and maybe find places where the developers can add some assert statements or something to handle errors...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.