Question & Answer
Question
How do you stub macros in IBM Rational Test RealTime?
Cause
Macros cannot be stubbed. You can only stub C functions and C++ methods.
Answer
The macros that you stub needs to be converted to a C function or C++ method call .
Below is a sample on how to convert a C macro to a function call and stub it.
Example : You have the following macro defined in the file calc.h.
#define doAdd(x,y) (x + y)
Then it can be redefined to a C function call as below:
function call:
#ifndef doAdd
#define doAdd(x,y) (x + y)
#endif
Now in the DCL file you can write
#{
#define doAdd(x,y) stubAdd(x,y)
extern int stubAdd(int x, int y);
#include "calc.h"
#include "calc.cpp"
}#
Note: For code under test to be included, such that the new macro definition takes affect in the code, you need to modify the .STB file
STUB stubAdd : int stubAdd(int x, int y)
{
PRINT ("In stubAdd");
...
#return (x + y);
}
Attached is the sample snippet of the code.
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21622389