# SDL Visual Test: C:/Users/DELL/Work/sdlvisualtest/visualtest/src/variator_common.c File Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
variator_common.c File Reference
`#include <SDL_test.h>`
`#include "SDL_visualtest_variator_common.h"`

## Functions

int | SDLVisualTest_NextValue (SDLVisualTest_SUTOptionValue *var, SDLVisualTest_SUTOption *opt)
int | SDLVisualTest_MakeStrFromVariation (SDLVisualTest_Variation *variation, SDLVisualTest_SUTConfig *config, char *buffer, int size)
int | SDLVisualTest_InitVariation (SDLVisualTest_Variation *variation, SDLVisualTest_SUTConfig *config)

## Detailed Description

Source file for some common functionality used by variators.

## Function Documentation

int SDLVisualTest_InitVariation | ( | SDLVisualTest_Variation * | variation,
|  | SDLVisualTest_SUTConfig * | config
| ) |  |

Initializes the variation using the following rules:

- Boolean options are initialized to SDL_FALSE.
- Integer options are initialized to the minimum valid value they can hold.
- Enum options are initialized to the first element in the list of values they can take.
- String options are initialized to the name of the option.

Returns
  1 on success, 0 on failure.

int SDLVisualTest_MakeStrFromVariation | ( | SDLVisualTest_Variation * | variation,
|  | SDLVisualTest_SUTConfig * | config,
|  | char * | buffer,
|  | int | size
| ) |  |

Converts a variation object into a string of command line arguments.

Parameters

  variation | Variation object to be converted.
  config | Config object for the SUT.
  buffer | Pointer to the buffer the arguments string will be copied into.
  size | Size of the buffer.

Returns
  1 on success, 0 on failure

int SDLVisualTest_NextValue | ( | SDLVisualTest_SUTOptionValue * | var,
|  | SDLVisualTest_SUTOption * | opt
| ) |  |

"Increments" the value of the option by one and returns the carry. We wrap around to the initial value on overflow which makes the carry one. For example: "incrementing" an SDL_FALSE option makes it SDL_TRUE with no carry, and "incrementing" an SDL_TRUE option makes it SDL_FALSE with carry one. For integers, a random value in the valid range for the option is used.

Parameters

  var | Value of the option
  opt | Object with metadata about the option

Returns
  1 if there is a carry for enum and bool type options, 0 otherwise. 1 is always returned for integer and string type options. -1 is returned on error.