Main Content

Functions and Data Types Not Supported for Graphical Test Authoring in Polyspace Platform User Interface

A C/C++ unit test calls one or more functions and checks if a function return value or other side effects of a function agree with expected values. You can author unit tests graphically in the Polyspace Platform user interface or by using a C/C++ xUnit-based API.

The graphical test authoring workflow is supported only for functions with specific input data types. If your function has unsupported input types, when you parse your code, you can see a warning message such as the following:

Some functions are not supported for graphical test authoring.
Unsupported functions do not appear on the Projects pane. However, on the Code pane, you can see all functions in the project, whether supported for graphical test authoring or not. If a function or type is not supported for graphical test authoring, when you select it, you see the property Supported in graphical tests set to false.

Alternatives to Graphical Test Authoring

If a function is not supported for graphical test authoring, you can test the function using the C/C++ xUnit-based API and add those tests to your project. For more information, see:

Alternatively, within a graphical test, you can enter scripted steps along with graphically authored steps, and invoke unsupported functions in the scripted steps. You can enter C/C++ code in scripted steps without going through the learning curve of the Polyspace® Test™ xUnit API. To assess variables in scripted steps, instead of using macros from the xUnit API, you can simply add the variable names as observables in a table, and then add assessments on those observables just as you do in graphical steps. For more information, see Test C/C++ Functions by Using Scripts in Graphical Tests.

Unsupported Functions and Types

The following sections list some of the limitations of graphical test authoring in the Polyspace Platform user interface.

User-Defined Data Types Not Defined in Headers

If a user-defined data type has the type definition in a source file and not a header, a function with inputs of that type is not supported for graphical test authoring. The reason is that at build time, the type definition is available only to the unit containing the source file and cannot be accessed from tests.

For instance, you cannot write a test for the function getNumber() or getNumEntries() defined in a source file as follows:

typedef int Int;
typedef struct database {
    int entries;
    char *first;
    char *last;
} db;

Int getNumber (Int aNumber) {
    return aNumber > 0? aNumber: 0;
}

int getNumEntries (db allData) {
    return allData.entries;
}
To write a test for this function, move the definition of the type db to a header file and provide the path containing the header file as an include folder in your project configuration. See also Include paths (-I).

Function Pointers

Functions with inputs of function pointer type are not supported for graphical test authoring.

Functions with Default Arguments (C++)

Functions that have default arguments are only partially supported for graphical test authoring. For instance, if you write a test for the function multiplyAndAdd() defined as follows, you have to explicitly specify values of all inputs, even the ones with default values:

int multiplyAndAdd (int x, int factor = 2, int increment = 1) {
    return x * factor + increment;
}

Inline Functions

Inline functions are not directly supported for graphical test authoring. However, you can write tests for callers of inline functions.

Member Functions Hidden by Macros (C++)

Class member functions that have the same name as a macro are not supported for test case authoring.

For instance, consider the following example:

class DeviceManager {
   void listAllDevices() {
      //...
   }
};

DeviceManager Mgr;
#define listAllDevices Mgr.listAllDevices
In this example, the member function listAllDevices in the class DeviceManager is hidden by the macro listAllDevices. Functions such as this are not supported for graphical test authoring.

Functions Requiring User Input

If a function contains calls to Standard Library functions such as scanf() and requires user input at execution time, you cannot write a graphical test for the function since graphical tests do not allow user input specification at execution time.

Multilevel Pointers

If a function input is of pointer-to-pointer type, the function is not supported for graphical test authoring. For instance:

  • The function func() has an input of pointer-to-pointer type:

    void func(int** a){}
  • The function func() has as input a pointer to a dynamically sized array:

    void func(int* a[]) {}

Multidimensional Arrays

You cannot author graphical tests for multidimensional arrays if any dimension other than the first dimension is unknown.

For instance, you can generate tests for the function oneDimensionalVLA():

void oneDimensionalVLA(int size, int array[size]) {}
But not for the function multiDimVLA():
void multiDimVLA(int size1, int size2, int array[size1][size2]) {}

Static Variables

Functions that update function-scope static variables are not fully supported for graphical test authoring. You can author a graphical test for such functions but the tests use the value of the static variables set in the source file. You cannot explicitly set the static variables in the test.

Functions that update file-scope static variables are fully supported for graphical test authoring.

Structures with Flexible Array Members

If a function input has a structured data type where the structure contains a flexible array member, the function is not supported for graphical test authoring.

For instance, the function func_unbounded_array() is not supported for graphical test authoring:

typedef struct {
    int i;
    int array[];
} unbounded_array_t;


void func_unbounded_array(unbounded_array_t arg) {}

Variadic Functions

Variadic functions are not supported for graphical test authoring.

Functions and Types with Limited Support

The following sections list functions and types that are supported for graphical test authoring, but not all test authoring conveniences are available.

Types Not Supported for Parametrized Tests

You cannot create a test parameter for variables that have certain data types, for instance, union types. For more details on this limitation, see Run Same Test with Different Inputs in Polyspace Platform User Interface.

See Also

Topics