Displaying Actual Values in Execution Report with User Code

Question:
Is there a setting that will show the actual values with user code?
Answer:

VectorCAST contains an un-documented feature to allow expected user code to be displayed in the execution report with an arbitrary label and with the actual value displayed. To use this feature, your user code will need to make an explicit call to a new harness function called vCAST_UC_WRITE_EXPECTED. This harness function will record the result of evaluating an arbitrary test condition, along with the label and actual value you specify.
 

For example, you might replace user code that used to look like this:

{ <<uut.func.return>> == 1 }

with this instead:

char actual[20];
double return_value = <<uut.func.return>>;
snprintf( actual, 20, "%lg", return_value );
vCAST_UC_WRITE_EXPECTED( "uut.func.return",
"Verify <<uut.func.return>> is 1.2+/-.1",
((1.1 <= return_value) && (return_value <= 1.3)),
actual );

The prototype for vCAST_UC_WRITE_EXPECTED is:

void vCAST_UC_WRITE_EXPECTED (const char *param, const char *name, int match, const char *actual);

The parameters are:

  • const char *param - This corresponds to the user code tag (sans angle brackets) for the parameter or global being checked. This is used by VectorCAST to determine what cell to color in the parameter tree. An empty string can be used if you do not care about the coloring of the parameter tree. If a non-empty string is used, it *must* correspond to a valid harness variable.
  • const char *name - This is the text which will be used as a label for the user code when it is shown in the execution report.
  • int match - If this is non-zero, the user code condition is considered matched. If it is 0, the user code is considered not matched (failed).
  • const char *actual - If this is non-NULL, it should point to a printable string representing the actual value of the variable being tested.
     


Article ID: 1482
Last updated: 2019-10-29
Revision: 3
VectorCAST -> C++ Unit Testing -> Displaying Actual Values in Execution Report with User Code
https://kb.vector.com/entry/1482/