Search tips

apple banana
Find rows that contain at least one of the two words.

+apple +juice
Find rows that contain both words.

+apple macintosh
Find rows that contain the word 'apple', but rank rows higher if they also contain 'macintosh'.

+apple -macintosh
Find rows that contain the word 'apple' but not 'macintosh'.

+apple ~macintosh
Find rows that contain the word 'apple', but if the row also contains the word 'macintosh', rate it lower than if row does not. This is "softer" than a search for '+apple -macintosh', for which the presence of 'macintosh' causes the row not to be returned at all.

+apple +(>turnover >strudel)
Find rows that contain the words 'apple' and 'turnover', or 'apple' and 'strudel' (in any order), but rank 'apple turnover' higher than 'apple strudel'.

Find rows that contain words such as 'apple', 'apples', 'applesauce', or 'applet'.

"some words"
Find rows that contain the exact phrase 'some words' (for example, rows that contain 'some words of wisdom' but not "some noise words").

By continuing to use this site you agree to the use of cookies. For more information and to find out how to change this click here. Accept Cookies
Please enable cookies in your browser for this website.
Advanced search

Initialize an Array of Structures before Running a Test Case

Last updated: 2019-12-03

This example will demonstrate how to initialize a global array of structures, before running a test case.  

The example function totals up the elements of an array of structures. Here is some example code where add_struct() is the function under test:

// Start of Example
struct basicStruct
  int field1;
  int field2;
  int field3;

#define ARRAY_SIZE 10
struct basicStruct arrayOfStruct [ARRAY_SIZE];

int add_struct()
    int sum_this, i;
    int ttl_sum = 0;

    for (i=0; i<ARRAY_SIZE; i++)
        sum_this =  arrayOfStruct[i].field1 + arrayOfStruct[i].field2 + arrayOfStruct[i].field3;
        ttl_sum += sum_this;
// End of Example


There are a couple ways you can initialize the array, as follows:

  1. If the array is rather small, say 5 elements or less, you can fill in the first element of the array and then do copy/paste to fill in the other elements. Once you have the first element of the array initialized, go to the input values column and do right click -> Copy.  

    Once you do that, the other elements of the array should be highlighted in blue to indicate they are paste candidates. Now, go to the input values column for each of the other elements and do right click -> Paste.  

    Note: You do not need to select the input values box in order to do copy/paste. All you have to do is hover over it before doing copy/paste.

  2. The second method will use testcase user code to accomplish the task. This is more flexible and is better for large arrays. Go to the test case editor and select the testcase user code tab at the bottom. On the left side (i.e. input side) of the pane, select the enable button. Any code that is entered here will run before the test case is run. This is where you would write the code to initialize the array.

    Make sure to take advantage of the test compile button. It is much easier to find compiler issues just after you entered the code, as opposed to when you try to run the test case.

    Note: Since testcase user code is part of the test case, you do not have to rebuild the environment. This will save you time if you want to repeatedly run the test with a variety of values.
Article Options
Views: 181