visualtest/src/variators.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 21 Oct 2018 22:40:17 -0400
changeset 12345 50e1cca28b39
parent 7924 fcb86d323770
permissions -rw-r--r--
wasapi/win32: Sort initial device lists by device GUID.

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