Using native C++ statements
Component Testing for C++
In some cases, it can be necessary to include portions of C++ native code inside an .otc or .otd test script for one the following reasons:
-
To declare native variables that participate in the flow of a scenario. Such statements must be analyzed by the Component Testing Parser.
-
To insert native code into a scenario. In this case, the code is ignored by the parser, but carried on into the generated code.
Analyzed native code
Lines prefixed with a # character are analyzed by Component Testing Parser.
Prefix statements with a # character to include native C++ variable declarations as well as any code that can be analyzed by the parser.
#int i;
#char *foo;
Variable declarations must be placed outside of Component Testing Language blocks or preferably at the beginning of scenarios and procedures.
Ignored native code
Lines prefixed with a @ character are ignored by the parser, but copied into the generated code.
To use native C++ code in the test script, start instructions with a @ character:
@for(i=0; i++; i<100) func(i);
@foo(a,&b,c);
You can add native code either inside or outside of C++ Test Script Language blocks.
Related topics
C++ contract check script | C++ test driver script