test/testautomation_audio.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Mon, 07 Jul 2014 20:26:21 -0700
changeset 8989 25582ffe1dec
parent 8853 a25dcbe4fb02
child 8994 b80b0595975c
permissions -rw-r--r--
Enable 2 disabled audio tests (since bug 1396 is fixed and they pass now)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Original code: automated SDL audio test written by Edgar Simo "bobbens"
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 * New/updated tests: aschiffler at ferzkopp dot net
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
#include <stdio.h>
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
     7
#include <string.h>
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
#include "SDL.h"
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
#include "SDL_test.h"
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
/* ================= Test Case Implementation ================== */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
/* Fixture */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
void
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
_audioSetUp(void *arg)
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    19
    /* Start SDL audio subsystem */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    20
    int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
        SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    22
    SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    23
    if (ret != 0) {
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
           SDLTest_LogError("%s", SDL_GetError());
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
        }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    29
/* Test callback function */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    30
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    31
{
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    32
   /* TODO: add tracking if callback was called */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    33
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    34
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    35
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
/* Test case functions */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
/**
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    39
 * \brief Stop and restart audio subsystem
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    40
 *
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    41
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitSubSystem
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    42
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitSubSystem
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    43
 */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    44
int audio_quitInitAudioSubSystem()
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    45
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    46
    /* Stop SDL audio subsystem */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    47
    SDL_QuitSubSystem( SDL_INIT_AUDIO );
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    48
        SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    49
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    50
        /* Restart audio again */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    51
        _audioSetUp(NULL);
7126
6fce42265686 Added missing return statements in test suite for audio.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7094
diff changeset
    52
6fce42265686 Added missing return statements in test suite for audio.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7094
diff changeset
    53
    return TEST_COMPLETED;
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    54
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    55
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    56
/**
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    57
 * \brief Start and stop audio directly
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    58
 *
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    59
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    60
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    61
 */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    62
int audio_initQuitAudio()
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    63
{
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    64
        int result;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    65
    int i, iMax;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    66
    const char* audioDriver;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    67
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    68
    /* Stop SDL audio subsystem */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    69
    SDL_QuitSubSystem( SDL_INIT_AUDIO );
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    70
        SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    71
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    72
        /* Loop over all available audio drivers */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    73
        iMax = SDL_GetNumAudioDrivers();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    74
        SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    75
        SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    76
        for (i = 0; i < iMax; i++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    77
            audioDriver = SDL_GetAudioDriver(i);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    78
            SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    79
            SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
    80
            SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    81
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    82
            /* Call Init */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    83
            result = SDL_AudioInit(audioDriver);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    84
            SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    85
            SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    86
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    87
            /* Call Quit */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    88
            SDL_AudioQuit();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    89
            SDLTest_AssertPass("Call to SDL_AudioQuit()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    90
    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    91
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    92
    /* NULL driver specification */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    93
    audioDriver = NULL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    94
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    95
    /* Call Init */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    96
    result = SDL_AudioInit(audioDriver);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    97
    SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    98
    SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    99
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   100
    /* Call Quit */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   101
    SDL_AudioQuit();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   102
    SDLTest_AssertPass("Call to SDL_AudioQuit()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   103
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   104
        /* Restart audio again */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   105
        _audioSetUp(NULL);
7126
6fce42265686 Added missing return statements in test suite for audio.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7094
diff changeset
   106
6fce42265686 Added missing return statements in test suite for audio.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7094
diff changeset
   107
    return TEST_COMPLETED;
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   108
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   109
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   110
/**
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   111
 * \brief Start, open, close and stop audio
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   112
 *
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   113
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   114
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_OpenAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   115
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_CloseAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   116
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   117
 */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   118
int audio_initOpenCloseQuitAudio()
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   119
{
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   120
    int result;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   121
    int i, iMax, j;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   122
    const char* audioDriver;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   123
    SDL_AudioSpec desired;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   124
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   125
    /* Stop SDL audio subsystem */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   126
    SDL_QuitSubSystem( SDL_INIT_AUDIO );
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   127
        SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   128
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   129
        /* Loop over all available audio drivers */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   130
        iMax = SDL_GetNumAudioDrivers();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   131
        SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   132
        SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   133
        for (i = 0; i < iMax; i++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   134
            audioDriver = SDL_GetAudioDriver(i);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   135
            SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   136
            SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   137
            SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   138
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   139
            /* Change specs */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   140
            for (j = 0; j < 2; j++) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   141
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   142
                /* Call Init */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   143
                result = SDL_AudioInit(audioDriver);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   144
                SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   145
                SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   146
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   147
                /* Set spec */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   148
                SDL_memset(&desired, 0, sizeof(desired));
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   149
                switch (j) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   150
                    case 0:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   151
                    /* Set standard desired spec */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   152
                    desired.freq = 22050;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   153
                    desired.format = AUDIO_S16SYS;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   154
                    desired.channels = 2;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   155
                    desired.samples = 4096;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   156
                    desired.callback = _audio_testCallback;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   157
                    desired.userdata = NULL;
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   158
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   159
                    case 1:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   160
                    /* Set custom desired spec */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   161
                    desired.freq = 48000;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   162
                    desired.format = AUDIO_F32SYS;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   163
                    desired.channels = 2;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   164
                    desired.samples = 2048;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   165
                    desired.callback = _audio_testCallback;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   166
                    desired.userdata = NULL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   167
                    break;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   168
            }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   169
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   170
            /* Call Open */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   171
            result = SDL_OpenAudio(&desired, NULL);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   172
            SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   173
            SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   174
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   175
            /* Call Close */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   176
                    SDL_CloseAudio();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   177
                    SDLTest_AssertPass("Call to SDL_CloseAudio()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   178
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   179
            /* Call Quit */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   180
            SDL_AudioQuit();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   181
            SDLTest_AssertPass("Call to SDL_AudioQuit()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   182
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   183
        } /* spec loop */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   184
    } /* driver loop */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   185
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   186
        /* Restart audio again */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   187
        _audioSetUp(NULL);
7126
6fce42265686 Added missing return statements in test suite for audio.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7094
diff changeset
   188
6fce42265686 Added missing return statements in test suite for audio.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7094
diff changeset
   189
    return TEST_COMPLETED;
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   190
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   191
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   192
/**
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   193
 * \brief Enumerate and name available audio devices (output and capture).
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   194
 *
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   195
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   196
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   197
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   198
int audio_enumerateAndNameAudioDevices()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   199
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   200
   int t, tt;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   201
   int i, n, nn;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
   const char *name, *nameAgain;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   203
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   204
   /* Iterate over types: t=0 output device, t=1 input/capture device */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   205
   for (t=0; t<2; t++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   206
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   207
      /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   208
      n = SDL_GetNumAudioDevices(t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   209
      SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
6897
865811c9f372 Fix bug 1723: flipped log text in audio suite - thanks P. Wiesemann
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   210
      SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "capture" : "output", n);
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   211
      SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   212
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   213
      /* Variation of non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   214
      if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   215
         tt = t + SDLTest_RandomIntegerInRange(1,10);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   216
         nn = SDL_GetNumAudioDevices(tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   217
         SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   218
         nn = SDL_GetNumAudioDevices(-tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   219
         SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   220
      }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   221
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   222
      /* List devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   223
      if (n>0) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   224
         for (i=0; i<n; i++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   225
            name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   226
            SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   227
            SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   228
            if (name != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   229
              SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   230
              if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   231
                  /* Also try non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   232
                  tt = t + SDLTest_RandomIntegerInRange(1,10);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   233
                  nameAgain = SDL_GetAudioDeviceName(i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   234
                  SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   235
                  if (nameAgain != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   236
                    SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   237
                    SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   238
                      "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   239
                      i, t, i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   240
                  }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   241
               }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   242
            }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   243
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   244
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   245
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   246
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   247
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   248
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   249
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   250
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   251
 * \brief Negative tests around enumeration and naming of audio devices.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   252
 *
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   253
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   254
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   255
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   256
int audio_enumerateAndNameAudioDevicesNegativeTests()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   257
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   258
   int t;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   259
   int i, j, no, nc;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   260
   const char *name;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   261
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   262
   /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   263
   no = SDL_GetNumAudioDevices(0);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   264
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   265
   nc = SDL_GetNumAudioDevices(1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   266
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   267
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   268
   /* Invalid device index when getting name */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   269
   for (t=0; t<2; t++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   270
      /* Negative device index */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   271
      i = SDLTest_RandomIntegerInRange(-10,-1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   272
      name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   273
      SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   274
      SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   275
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   276
      /* Device index past range */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   277
      for (j=0; j<3; j++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   278
         i = (t) ? nc+j : no+j;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   279
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   280
         SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   281
         SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   282
      }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   283
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   284
      /* Capture index past capture range but within output range */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   285
      if ((no>0) && (no>nc) && (t==1)) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   286
         i = no-1;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   287
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   288
         SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   289
         SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   290
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   291
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   292
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   293
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   294
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   295
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   296
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   297
/**
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   298
 * \brief Checks available audio driver names.
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   299
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   300
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDrivers
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   301
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDriver
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   302
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   303
int audio_printAudioDrivers()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   304
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   305
   int i, n;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   306
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   307
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   308
   /* Get number of drivers */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   309
   n = SDL_GetNumAudioDrivers();
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   310
   SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   311
   SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   312
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   313
   /* List drivers. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   314
   if (n>0)
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   315
   {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   316
      for (i=0; i<n; i++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   317
         name = SDL_GetAudioDriver(i);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   318
         SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   319
         SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   320
         if (name != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   321
            SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   322
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   323
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   324
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   325
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   326
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   327
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   328
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   329
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   330
/**
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   331
 * \brief Checks current audio driver name with initialized audio.
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   332
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   333
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetCurrentAudioDriver
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   334
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   335
int audio_printCurrentAudioDriver()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   336
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   337
   /* Check current audio driver */
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   338
   const char *name = SDL_GetCurrentAudioDriver();
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   339
   SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   340
   SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   341
   if (name != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   342
      SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   343
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   344
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   345
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   346
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   347
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   348
/* Definition of all formats, channels, and frequencies used to test audio conversions */
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   349
const int _numAudioFormats = 18;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   350
SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   351
                AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32,
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   352
                                AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   353
char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   354
                "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32",
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   355
                                "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   356
const int _numAudioChannels = 4;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   357
Uint8 _audioChannels[] = { 1, 2, 4, 6 };
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   358
const int _numAudioFrequencies = 4;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   359
int _audioFrequencies[] = { 11025, 22050, 44100, 48000 };
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   360
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   361
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   362
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   363
 * \brief Builds various audio conversion structures
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   364
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   365
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_BuildAudioCVT
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   366
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   367
int audio_buildAudioCVT()
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   368
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   369
  int result;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   370
  SDL_AudioCVT  cvt;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   371
  SDL_AudioSpec spec1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   372
  SDL_AudioSpec spec2;
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   373
  int i, ii, j, jj, k, kk;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   374
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   375
  /* No conversion needed */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   376
  spec1.format = AUDIO_S16LSB;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   377
  spec1.channels = 2;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   378
  spec1.freq = 22050;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   379
  result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   380
                                   spec1.format, spec1.channels, spec1.freq);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   381
  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec1)");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   382
  SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0, got: %i", result);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   383
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   384
  /* Typical conversion */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   385
  spec1.format = AUDIO_S8;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   386
  spec1.channels = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   387
  spec1.freq = 22050;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   388
  spec2.format = AUDIO_S16LSB;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   389
  spec2.channels = 2;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   390
  spec2.freq = 44100;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   391
  result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   392
                                   spec2.format, spec2.channels, spec2.freq);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   393
  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   394
  SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   395
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   396
  /* All source conversions with random conversion targets, allow 'null' conversions */
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   397
  for (i = 0; i < _numAudioFormats; i++) {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   398
    for (j = 0; j < _numAudioChannels; j++) {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   399
      for (k = 0; k < _numAudioFrequencies; k++) {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   400
        spec1.format = _audioFormats[i];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   401
        spec1.channels = _audioChannels[j];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   402
        spec1.freq = _audioFrequencies[k];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   403
        ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   404
        jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   405
        kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   406
        spec2.format = _audioFormats[ii];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   407
        spec2.channels = _audioChannels[jj];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   408
        spec2.freq = _audioFrequencies[kk];
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   409
        result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   410
                                         spec2.format, spec2.channels, spec2.freq);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   411
        SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   412
            i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   413
        SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   414
        if (result<0) {
8853
a25dcbe4fb02 Fixed format string faults in audio tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7721
diff changeset
   415
          SDLTest_LogError("%s", SDL_GetError());
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   416
        } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   417
          SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   418
        }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   419
      }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   420
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   421
  }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   422
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   423
   return TEST_COMPLETED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   424
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   425
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   426
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   427
 * \brief Checkes calls with invalid input to SDL_BuildAudioCVT
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   428
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   429
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_BuildAudioCVT
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   430
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   431
int audio_buildAudioCVTNegative()
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   432
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   433
  const char *expectedError = "Parameter 'cvt' is invalid";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   434
  const char *error;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   435
  int result;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   436
  SDL_AudioCVT  cvt;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   437
  SDL_AudioSpec spec1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   438
  SDL_AudioSpec spec2;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   439
  int i;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   440
  char message[256];
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   441
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   442
  /* Valid format */
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   443
  spec1.format = AUDIO_S8;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   444
  spec1.channels = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   445
  spec1.freq = 22050;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   446
  spec2.format = AUDIO_S16LSB;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   447
  spec2.channels = 2;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   448
  spec2.freq = 44100;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   449
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   450
  SDL_ClearError();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   451
  SDLTest_AssertPass("Call to SDL_ClearError()");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   452
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   453
  /* NULL input for CVT buffer */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   454
  result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq,
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   455
                                                   spec2.format, spec2.channels, spec2.freq);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   456
  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   457
  SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   458
  error = SDL_GetError();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   459
  SDLTest_AssertPass("Call to SDL_GetError()");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   460
  SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   461
  if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   462
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   463
          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   464
  }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   465
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   466
  /* Invalid conversions */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   467
  for (i = 1; i < 64; i++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   468
    /* Valid format to start with */
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   469
    spec1.format = AUDIO_S8;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   470
    spec1.channels = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   471
    spec1.freq = 22050;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   472
    spec2.format = AUDIO_S16LSB;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   473
    spec2.channels = 2;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   474
    spec2.freq = 44100;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   475
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   476
    SDL_ClearError();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   477
    SDLTest_AssertPass("Call to SDL_ClearError()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   478
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   479
    /* Set various invalid format inputs */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   480
    SDL_strlcpy(message, "Invalid: ", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   481
    if (i & 1) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   482
        SDL_strlcat(message, " spec1.format", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   483
        spec1.format = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   484
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   485
    if (i & 2) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   486
        SDL_strlcat(message, " spec1.channels", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   487
        spec1.channels = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   488
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   489
    if (i & 4) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   490
        SDL_strlcat(message, " spec1.freq", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   491
        spec1.freq = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   492
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   493
    if (i & 8) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   494
        SDL_strlcat(message, " spec2.format", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   495
        spec2.format = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   496
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   497
    if (i & 16) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   498
        SDL_strlcat(message, " spec2.channels", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   499
        spec2.channels = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   500
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   501
    if (i & 32) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   502
        SDL_strlcat(message, " spec2.freq", 256);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   503
        spec2.freq = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   504
    }
8853
a25dcbe4fb02 Fixed format string faults in audio tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7721
diff changeset
   505
    SDLTest_Log("%s", message);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   506
    result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   507
                                   spec2.format, spec2.channels, spec2.freq);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   508
    SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   509
    SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   510
    error = SDL_GetError();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   511
    SDLTest_AssertPass("Call to SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   512
    SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty");
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   513
  }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   514
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   515
  SDL_ClearError();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   516
  SDLTest_AssertPass("Call to SDL_ClearError()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   517
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   518
  return TEST_COMPLETED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   519
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   520
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   521
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   522
 * \brief Checks current audio status.
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   523
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   524
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioStatus
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   525
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   526
int audio_getAudioStatus()
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   527
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   528
   SDL_AudioStatus result;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   529
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   530
   /* Check current audio status */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   531
   result = SDL_GetAudioStatus();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   532
   SDLTest_AssertPass("Call to SDL_GetAudioStatus()");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   533
   SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   534
        "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   535
        SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   536
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   537
   return TEST_COMPLETED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   538
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   539
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   540
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   541
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   542
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   543
 * \brief Opens, checks current audio status, and closes a device.
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   544
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   545
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioStatus
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   546
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   547
int audio_openCloseAndGetAudioStatus()
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   548
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   549
   SDL_AudioStatus result;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   550
   int i;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   551
   int count;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   552
   char *device;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   553
   SDL_AudioDeviceID id;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   554
   SDL_AudioSpec desired, obtained;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   555
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   556
   /* Get number of devices. */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   557
   count = SDL_GetNumAudioDevices(0);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   558
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   559
   if (count > 0) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   560
     for (i = 0; i < count; i++) {
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   561
       /* Get device name */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   562
       device = (char *)SDL_GetAudioDeviceName(i, 0);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   563
       SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   564
       SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   565
       if (device == NULL) return TEST_ABORTED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   566
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   567
       /* Set standard desired spec */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   568
       desired.freq=22050;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   569
       desired.format=AUDIO_S16SYS;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   570
       desired.channels=2;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   571
       desired.samples=4096;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   572
       desired.callback=_audio_testCallback;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   573
       desired.userdata=NULL;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   574
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   575
       /* Open device */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   576
       id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   577
       SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   578
       SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   579
       if (id > 1) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   580
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   581
         /* Check device audio status */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   582
         result = SDL_GetAudioDeviceStatus(id);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   583
         SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   584
         SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   585
            "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   586
            SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   587
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   588
         /* Close device again */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   589
         SDL_CloseAudioDevice(id);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   590
         SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   591
       }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   592
     }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   593
   } else {
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   594
     SDLTest_Log("No devices to test with");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   595
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   596
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   597
   return TEST_COMPLETED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   598
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   599
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   600
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   601
 * \brief Locks and unlocks open audio device.
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   602
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   603
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_LockAudioDevice
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   604
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_UnlockAudioDevice
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   605
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   606
int audio_lockUnlockOpenAudioDevice()
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   607
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   608
   int i;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   609
   int count;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   610
   char *device;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   611
   SDL_AudioDeviceID id;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   612
   SDL_AudioSpec desired, obtained;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   613
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   614
   /* Get number of devices. */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   615
   count = SDL_GetNumAudioDevices(0);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   616
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   617
   if (count > 0) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   618
     for (i = 0; i < count; i++) {
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   619
       /* Get device name */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   620
       device = (char *)SDL_GetAudioDeviceName(i, 0);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   621
       SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   622
       SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   623
       if (device == NULL) return TEST_ABORTED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   624
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   625
       /* Set standard desired spec */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   626
       desired.freq=22050;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   627
       desired.format=AUDIO_S16SYS;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   628
       desired.channels=2;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   629
       desired.samples=4096;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   630
       desired.callback=_audio_testCallback;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   631
       desired.userdata=NULL;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   632
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   633
       /* Open device */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   634
       id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   635
       SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   636
       SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   637
       if (id > 1) {
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   638
         /* Lock to protect callback */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   639
         SDL_LockAudioDevice(id);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   640
         SDLTest_AssertPass("SDL_LockAudioDevice(%i)", id);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   641
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   642
         /* Simulate callback processing */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   643
         SDL_Delay(10);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   644
         SDLTest_Log("Simulate callback processing - delay");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   645
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   646
         /* Unlock again */
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   647
         SDL_UnlockAudioDevice(id);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   648
         SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   649
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   650
         /* Close device again */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   651
         SDL_CloseAudioDevice(id);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   652
         SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   653
       }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   654
     }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   655
   } else {
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   656
     SDLTest_Log("No devices to test with");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   657
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   658
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   659
   return TEST_COMPLETED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   660
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   661
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   662
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   663
/**
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   664
 * \brief Convert audio using various conversion structures
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   665
 *
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   666
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_BuildAudioCVT
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   667
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_ConvertAudio
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   668
 */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   669
int audio_convertAudio()
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   670
{
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   671
  int result;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   672
  SDL_AudioCVT  cvt;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   673
  SDL_AudioSpec spec1;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   674
  SDL_AudioSpec spec2;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   675
  int c;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   676
  char message[128];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   677
  int i, ii, j, jj, k, kk, l, ll;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   678
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   679
  /* Iterate over bitmask that determines which parameters are modified in the conversion */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   680
  for (c = 1; c < 8; c++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   681
    SDL_strlcpy(message, "Changing:", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   682
    if (c & 1) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   683
      SDL_strlcat(message, " Format", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   684
    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   685
    if (c & 2) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   686
      SDL_strlcat(message, " Channels", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   687
    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   688
    if (c & 4) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   689
      SDL_strlcat(message, " Frequencies", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   690
    }
8853
a25dcbe4fb02 Fixed format string faults in audio tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7721
diff changeset
   691
    SDLTest_Log("%s", message);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   692
    /* All source conversions with random conversion targets */
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   693
    for (i = 0; i < _numAudioFormats; i++) {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   694
      for (j = 0; j < _numAudioChannels; j++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   695
        for (k = 0; k < _numAudioFrequencies; k++) {
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   696
          spec1.format = _audioFormats[i];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   697
          spec1.channels = _audioChannels[j];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   698
          spec1.freq = _audioFrequencies[k];
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   699
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   700
          /* Ensure we have a different target format */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   701
          do {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   702
            if (c & 1) {
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   703
              ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   704
            } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   705
              ii = 1;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   706
            }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   707
            if (c & 2) {
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   708
              jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   709
            } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   710
              jj= j;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   711
            }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   712
            if (c & 4) {
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   713
              kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   714
            } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   715
              kk = k;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   716
            }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   717
          } while ((i == ii) && (j == jj) && (k == kk));
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   718
          spec2.format = _audioFormats[ii];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   719
          spec2.channels = _audioChannels[jj];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   720
          spec2.freq = _audioFrequencies[kk];
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   721
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   722
          result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   723
                                           spec2.format, spec2.channels, spec2.freq);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   724
          SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7126
diff changeset
   725
            i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   726
          SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   727
          if (result != 1) {
8853
a25dcbe4fb02 Fixed format string faults in audio tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7721
diff changeset
   728
            SDLTest_LogError("%s", SDL_GetError());
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   729
          } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   730
            SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   731
            if (cvt.len_mult < 1) return TEST_ABORTED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   732
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   733
            /* Create some random data to convert */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   734
            l = 64;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   735
            ll = l * cvt.len_mult;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   736
            SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, ll);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   737
            cvt.len = l;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   738
            cvt.buf = (Uint8 *)SDL_malloc(ll);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   739
            SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   740
            if (cvt.buf == NULL) return TEST_ABORTED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   741
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   742
            /* Convert the data */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   743
            result = SDL_ConvertAudio(&cvt);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   744
            SDLTest_AssertPass("Call to SDL_ConvertAudio()");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   745
            SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   746
            SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   747
            SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   748
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   749
            /* Free converted buffer */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   750
            SDL_free(cvt.buf);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   751
            cvt.buf = NULL;
7719
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7677
diff changeset
   752
          }
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   753
        }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   754
      }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   755
    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   756
  }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   757
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   758
   return TEST_COMPLETED;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   759
}
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   760
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   761
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   762
/**
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   763
 * \brief Opens, checks current connected status, and closes a device.
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   764
 *
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   765
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_AudioDeviceConnected
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   766
 */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   767
int audio_openCloseAudioDeviceConnected()
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   768
{
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6830
diff changeset
   769
   int result = -1;
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   770
   int i;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   771
   int count;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   772
   char *device;
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   773
   SDL_AudioDeviceID id;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   774
   SDL_AudioSpec desired, obtained;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   775
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   776
   /* Get number of devices. */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   777
   count = SDL_GetNumAudioDevices(0);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   778
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   779
   if (count > 0) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   780
     for (i = 0; i < count; i++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   781
       /* Get device name */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   782
       device = (char *)SDL_GetAudioDeviceName(i, 0);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   783
       SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   784
       SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   785
       if (device == NULL) return TEST_ABORTED;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   786
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   787
       /* Set standard desired spec */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   788
       desired.freq=22050;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   789
       desired.format=AUDIO_S16SYS;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   790
       desired.channels=2;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   791
       desired.samples=4096;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   792
       desired.callback=_audio_testCallback;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   793
       desired.userdata=NULL;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   794
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   795
       /* Open device */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   796
       id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   797
       SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6830
diff changeset
   798
       SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %i", id);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   799
       if (id > 1) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   800
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   801
/* TODO: enable test code when function is available in SDL2 */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   802
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   803
#ifdef AUDIODEVICECONNECTED_DEFINED
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   804
         /* Get connected status */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   805
         result = SDL_AudioDeviceConnected(id);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   806
         SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   807
#endif
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6830
diff changeset
   808
         SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   809
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   810
         /* Close device again */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   811
         SDL_CloseAudioDevice(id);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   812
         SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   813
       }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   814
     }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   815
   } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   816
     SDLTest_Log("No devices to test with");
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   817
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   818
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   819
   return TEST_COMPLETED;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   820
}
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   821
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   822
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   823
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   824
/* ================= Test Case References ================== */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   825
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   826
/* Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   827
static const SDLTest_TestCaseReference audioTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   828
        { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   829
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   830
static const SDLTest_TestCaseReference audioTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   831
        { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   832
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   833
static const SDLTest_TestCaseReference audioTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   834
        { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   835
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   836
static const SDLTest_TestCaseReference audioTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   837
        { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   838
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   839
static const SDLTest_TestCaseReference audioTest5 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   840
        { (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED };
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   841
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   842
static const SDLTest_TestCaseReference audioTest6 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   843
        { (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED };
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   844
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   845
static const SDLTest_TestCaseReference audioTest7 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   846
        { (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED };
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   847
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   848
static const SDLTest_TestCaseReference audioTest8 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   849
        { (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED };
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   850
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   851
static const SDLTest_TestCaseReference audioTest9 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   852
        { (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED };
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   853
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   854
/* TODO: enable test when SDL_ConvertAudio segfaults on cygwin have been fixed.    */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   855
/* For debugging, test case can be run manually using --filter audio_convertAudio  */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   856
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   857
static const SDLTest_TestCaseReference audioTest10 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   858
        { (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED };
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   859
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   860
/* TODO: enable test when SDL_AudioDeviceConnected has been implemented.           */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   861
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   862
static const SDLTest_TestCaseReference audioTest11 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   863
        { (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED };
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   864
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   865
static const SDLTest_TestCaseReference audioTest12 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   866
        { (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED };
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   867
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   868
static const SDLTest_TestCaseReference audioTest13 =
8989
25582ffe1dec Enable 2 disabled audio tests (since bug 1396 is fixed and they pass now)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 8853
diff changeset
   869
        { (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED };
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   870
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   871
static const SDLTest_TestCaseReference audioTest14 =
8989
25582ffe1dec Enable 2 disabled audio tests (since bug 1396 is fixed and they pass now)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 8853
diff changeset
   872
        { (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED };
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   873
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   874
/* Sequence of Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   875
static const SDLTest_TestCaseReference *audioTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   876
    &audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   877
    &audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   878
    &audioTest12, &audioTest13, &audioTest14, NULL
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   879
};
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   880
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   881
/* Audio test suite (global) */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   882
SDLTest_TestSuiteReference audioTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   883
    "Audio",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   884
    _audioSetUp,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   885
    audioTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   886
    NULL
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   887
};