visualtest/src/variators.c
changeset 7924 fcb86d323770
equal deleted inserted replaced
7923:d9ecdf71effb 7924:fcb86d323770
       
     1 /* See COPYING.txt for the full license governing this code. */
       
     2 /**
       
     3  * \file variators.c
       
     4  *
       
     5  * Source file for the operations that act on variators.
       
     6  */
       
     7 
       
     8 #include <SDL_test.h>
       
     9 #include "SDL_visualtest_variators.h"
       
    10 
       
    11 int
       
    12 SDLVisualTest_InitVariator(SDLVisualTest_Variator* variator,
       
    13                            SDLVisualTest_SUTConfig* config,
       
    14                            SDLVisualTest_VariatorType type,
       
    15                            Uint64 seed)
       
    16 {
       
    17     if(!variator)
       
    18     {
       
    19         SDLTest_LogError("variator argument cannot be NULL");
       
    20         return 0;
       
    21     }
       
    22     if(!config)
       
    23     {
       
    24         SDLTest_LogError("config argument cannot be NULL");
       
    25         return 0;
       
    26     }
       
    27 
       
    28     variator->type = type;
       
    29     switch(type)
       
    30     {
       
    31         case SDL_VARIATOR_EXHAUSTIVE:
       
    32             return SDLVisualTest_InitExhaustiveVariator(&variator->data.exhaustive,
       
    33                                                         config);
       
    34         break;
       
    35 
       
    36         case SDL_VARIATOR_RANDOM:
       
    37             return SDLVisualTest_InitRandomVariator(&variator->data.random,
       
    38                                                     config, seed);
       
    39         break;
       
    40 
       
    41         default:
       
    42             SDLTest_LogError("Invalid value for variator type");
       
    43             return 0;
       
    44     }
       
    45     return 0;
       
    46 }
       
    47 
       
    48 char*
       
    49 SDLVisualTest_GetNextVariation(SDLVisualTest_Variator* variator)
       
    50 {
       
    51     if(!variator)
       
    52     {
       
    53         SDLTest_LogError("variator argument cannot be NULL");
       
    54         return NULL;
       
    55     }
       
    56     switch(variator->type)
       
    57     {
       
    58         case SDL_VARIATOR_EXHAUSTIVE:
       
    59             return SDLVisualTest_GetNextExhaustiveVariation(&variator->data.exhaustive);
       
    60         break;
       
    61 
       
    62         case SDL_VARIATOR_RANDOM:
       
    63             return SDLVisualTest_GetNextRandomVariation(&variator->data.random);
       
    64         break;
       
    65 
       
    66         default:
       
    67             SDLTest_LogError("Invalid value for variator type");
       
    68             return NULL;
       
    69     }
       
    70     return NULL;
       
    71 }
       
    72 
       
    73 void SDLVisualTest_FreeVariator(SDLVisualTest_Variator* variator)
       
    74 {
       
    75     if(!variator)
       
    76     {
       
    77         SDLTest_LogError("variator argument cannot be NULL");
       
    78         return;
       
    79     }
       
    80     switch(variator->type)
       
    81     {
       
    82         case SDL_VARIATOR_EXHAUSTIVE:
       
    83             SDLVisualTest_FreeExhaustiveVariator(&variator->data.exhaustive);
       
    84         break;
       
    85 
       
    86         case SDL_VARIATOR_RANDOM:
       
    87             SDLVisualTest_FreeRandomVariator(&variator->data.random);
       
    88         break;
       
    89 
       
    90         default:
       
    91             SDLTest_LogError("Invalid value for variator type");
       
    92     }
       
    93 }