Two aspects of programming with CxxTester are closely wired together. The contents of the testscript and the way of how this data is introduced to the target software.

Every testcase of the input script invokes a call into a testfunction which the appropriate name. Such a testfunction can be realised with a very few lines of code. A testfunctions workflow is divided in three sequences:

  1. reading of the input data via the DIN (data in) macro
  2. calling the target software with the input data as parameter
  3. storage of the resulting data via the DOUT (data out) macro


The following docu explains techniques concerning Step A.
The testscript content can be seen on the left side and the belonging read sequence of the testfunction on the right side.

 

There are three basic data types available:

param1 = 10                  // integer

int        i = DIN["param1"];

param2 = 12.34             // double

double d = DIN["param2"];

param3 = "hello world"   // string

char* str = DIN["param3"];

Other basic types of C++ must be supported by type convertions:

mode = 1   // int is used for a bool

int    m       = DIN["mode"];

 

bool mode = (bool)m;

Basic types can be assembled to structs (for more details see Structs):

Circle

char* color = DIN["Circle"]["color"];

{

int radius = DIN["Circle"]["radius"];

     color = "blue"

int cx = DIN["Circle"]["center"]["x"];

     center

int cy = DIN["Circle"]["center"]["y"];

     {

 

           x = 23

 

           y = 12

 

   }

 

     radius = 4

 

}

 

Input strings across multiple colums can be concatenated by brackets:

str = ( "this is "         "a longer"

char* str = DIN["str"];

         "string")

 

Hex values for integer types are possible:

val = 0xff3e

int i = DIN["val"];

Arrays can be defined multiple or explicit (for more details see Arrays):

arr[] { 100  200 300 }  //multiple

int val, i = 0;

arr[3]   = 400                 // explicit

while(DIN["arr"][i].getType() != 0)

arr[4]   = 500

{

arr[5]   = 600

   val = DIN["arr"][i];

arr[99] = 1000

   i++;

 

}

 

val = DIN["arr"][99];

It is possible to define all sort of input types (basics, structs and arrays) as global. As result they are available across the complete testscript not only for a single testcase: 

// a global section looks like a

 

// testcase without identifier

 

 

   // this is a structured global data

 

   point

 

   {

 

         px = 100

 

         py = 200

 

   }

 

   // this is a basic global data

 

   str = "hello"

 

}

 

 

 

testfunction

 

{

 

     myPoint = (point)

int      x     = DIN["myPoint"]["px"];

     myStr = (str)

int      y     = DIN["myPoint"]["py"];

}

char* strg = DIN["str"];

The C++ style comments between the first bracket and the first statements of a testcase is transfered into the resultscript. This allows to distinguish testcases with the same identifier.

testfunction

int i = DIN["var"];

{

// comments do not influence the

   // this comment will appear in the

// implementation of the testfunction

   // belonging text of the resultfile

 

   /* this C style comment will not

 

       appear in the resultfile */

 

 

 

   var = 10

 

}

 

The existance and type of a basic data item can be queried from the testfunction. If a testcase contains several statements which are using the same name, this will handled according the last one wins strategy:

foo  = 12.3

int t;

var  = "hello"

t = DIN["foo"].getType();  // t is 3

data = "world"

t = DIN["var"].getType();  // t is 2

data = 200

t = DIN["data"].getType(); // t is 1

 

t = DIN["xxx"].getType();  // t is 0

The keyword verify introduces the verify part of a testcase. All statements behind the verify keyword are used for the automatic check of the testcase results. Globals, struct and arrays can be used in the verify section as usual.

verify:

// the result data of a testcase is checked

   p >= 95

// against the data of te verify section

   p <= 100

// see below, how to create result data

   str = = "hello world"

 

   point.x != 12.34

 

Execution of Step B is business as usual.The input data which was accessed via DIN is now used to call the software which should be tested.

After that, the resulting data is returned to the testframework. This is called Step C, explained below.  The write sequence of the testfunction can be seen on the left side and the belonging output of the resultscript on the right side.

DOUT supports the same three basic types like DIN:

int r;

int      result = 1

char* str;

char*  color = "white"

double val;

double value = 12.5

//assume:

 

// r,str and val keep the testresults

 

DOUT["result"] = r;

 

DOUT["color"] = str;

 

DOUT["value"] = d;

 

Results can be structured like input data:

DOUT["point"]["px"] = 128;

int      point.px    = 128

DOUT["point"]["py"] = 76;

int      point.py    = 76

DOUT["point"]["color"] = "blue";

char* point.color = "blue"

Results can be written in arrays like input data:

DOUT["color"][3] = "red";

char*  color[3]        = "red"

DOUT["color"][4] = "blue";

char*  color[4]        = "blue"

DOUT["color"][5] = "green";

char*  color[5]        = "green"

DOUT["value"][17][5] = 3.4:

double value[17][5] = 3.4

It is possible to write results into the global storage by enclosing them into brackets. This makes the results available as input data for the following testcases:

DOUT["(var)"] = 200;

// no result or verification,

 

// var is written into global storage

If an integer is written into DOUT named with a preceding “0x”, the belonging statement of the resultfile will appear with the appropriate hexvalue:

DOUT["0xvar"] = 255;

int 0xvar = 0xFF

Write attempts into DOUT will be handled according the last one wins strategy:

DOUT["var"] = "hello";

int var = 200

DOUT["var"] = 100;

 

DOUT["var"] = 200;

 

HINT: the following testfunction is very helpful for visualization of input data, if DIN does not contain the input data like expected.

cxxcall(test)

// resultscript will contain

{

// complete input data

   DOUT = DIN;

 

}