test/testautomation_audio.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Tue, 23 Apr 2013 08:19:21 -0700
changeset 7094 330d3bb2476d
parent 7093 f0ede46d5ee7
child 7126 6fce42265686
permissions -rw-r--r--
Disable one test that crashes audio suite when run together with other tests
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
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
	/* Start SDL audio subsystem */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
	int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
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)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
	SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
	if (ret != 0) {
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
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    40
 * 
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
{
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    46
	/* Stop SDL audio subsystem */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    47
	SDL_QuitSubSystem( SDL_INIT_AUDIO );
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);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    52
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    53
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
 * \brief Start and stop audio directly
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
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    58
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    59
 */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    60
int audio_initQuitAudio()
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 result;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    63
	int i, iMax;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    64
	const char* audioDriver;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    65
	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    66
	/* Stop SDL audio subsystem */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    67
	SDL_QuitSubSystem( SDL_INIT_AUDIO );
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    68
        SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    69
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    70
        /* Loop over all available audio drivers */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    71
        iMax = SDL_GetNumAudioDrivers();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    72
        SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    73
        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
    74
        for (i = 0; i < iMax; i++) {
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    75
        	audioDriver = SDL_GetAudioDriver(i);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    76
        	SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    77
        	SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    78
        	SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    79
        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    80
        	/* Call Init */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    81
        	result = SDL_AudioInit(audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    82
        	SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    83
        	SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    84
        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    85
        	/* Call Quit */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    86
        	SDL_AudioQuit();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    87
        	SDLTest_AssertPass("Call to SDL_AudioQuit()");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    88
	}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    89
	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    90
	/* NULL driver specification */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    91
	audioDriver = NULL;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    92
	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    93
	/* Call Init */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    94
	result = SDL_AudioInit(audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    95
	SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    96
	SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    97
        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    98
	/* Call Quit */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
    99
	SDL_AudioQuit();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   100
	SDLTest_AssertPass("Call to SDL_AudioQuit()");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   101
      
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   102
        /* Restart audio again */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   103
        _audioSetUp(NULL);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   104
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   105
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   106
/**
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   107
 * \brief Start, open, close and stop audio
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
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   110
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_OpenAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   111
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_CloseAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   112
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   113
 */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   114
int audio_initOpenCloseQuitAudio()
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   115
{
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   116
        int result;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   117
	int i, iMax, j;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   118
	const char* audioDriver;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   119
	SDL_AudioSpec desired;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   120
	SDL_AudioSpec obtained;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   121
	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   122
	/* Stop SDL audio subsystem */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   123
	SDL_QuitSubSystem( SDL_INIT_AUDIO );
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   124
        SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   125
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   126
        /* Loop over all available audio drivers */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   127
        iMax = SDL_GetNumAudioDrivers();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   128
        SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   129
        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
   130
        for (i = 0; i < iMax; i++) {
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   131
        	audioDriver = SDL_GetAudioDriver(i);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   132
        	SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   133
        	SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   134
        	SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   135
        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   136
        	/* Change specs */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   137
        	for (j = 0; j < 2; j++) {
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   138
        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   139
        		/* Call Init */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   140
        		result = SDL_AudioInit(audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   141
        		SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   142
        		SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   143
        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   144
        		/* Set spec */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   145
        		SDL_memset(&desired, 0, sizeof(desired));
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   146
        		switch (j) {
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   147
        			case 0:
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   148
        			/* Set standard desired spec */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   149
        			desired.freq = 22050;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   150
        			desired.format = AUDIO_S16SYS;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   151
        			desired.channels = 2;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   152
        			desired.samples = 4096;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   153
        			desired.callback = _audio_testCallback;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   154
        			desired.userdata = NULL;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   155
        			
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   156
        			case 1:
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   157
        			/* Set custom desired spec */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   158
        			desired.freq = 48000;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   159
        			desired.format = AUDIO_F32SYS;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   160
        			desired.channels = 2;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   161
        			desired.samples = 2048;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   162
        			desired.callback = _audio_testCallback;
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   163
        			desired.userdata = NULL;        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   164
        			break;        			
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   165
			}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   166
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   167
			/* Call Open */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   168
			result = SDL_OpenAudio(&desired, NULL);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   169
			SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   170
			SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   171
			
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   172
			/* Call Close */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   173
        	        SDL_CloseAudio();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   174
        	        SDLTest_AssertPass("Call to SDL_CloseAudio()");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   175
        	        	
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   176
			/* Call Quit */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   177
			SDL_AudioQuit();
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   178
			SDLTest_AssertPass("Call to SDL_AudioQuit()");
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   179
			
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   180
		} /* spec loop */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   181
	} /* driver loop */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   182
	      
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   183
        /* Restart audio again */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   184
        _audioSetUp(NULL);
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   185
}
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   186
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   187
/**
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   188
 * \brief Enumerate and name available audio devices (output and capture).
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   189
 * 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   190
 * \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
   191
 * \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
   192
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   193
int audio_enumerateAndNameAudioDevices()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   194
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   195
   int t, tt;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   196
   int i, n, nn;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   197
   const char *name, *nameAgain;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   198
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   199
   /* 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
   200
   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
   201
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
      /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   203
      n = SDL_GetNumAudioDevices(t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   204
      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
   205
      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
   206
      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
   207
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   208
      /* Variation of non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   209
      if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   210
         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
   211
         nn = SDL_GetNumAudioDevices(tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   212
         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
   213
         nn = SDL_GetNumAudioDevices(-tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   214
         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
   215
      } 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   216
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   217
      /* List devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   218
      if (n>0) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   219
         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
   220
            name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   221
            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
   222
            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
   223
            if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   224
              SDLTest_AssertCheck(SDL_strlen(name)>0, "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   225
              if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   226
                  /* Also try non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   227
                  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
   228
                  nameAgain = SDL_GetAudioDeviceName(i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   229
                  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
   230
                  if (nameAgain != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   231
                    SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   232
                    SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   233
                      "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   234
                      i, t, i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   235
                  }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   236
               }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   237
            }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   238
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   239
      }
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
   return TEST_COMPLETED;
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
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   246
 * \brief Negative tests around enumeration and naming of audio devices.
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   247
 * 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   248
 * \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
   249
 * \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
   250
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   251
int audio_enumerateAndNameAudioDevicesNegativeTests()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   252
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   253
   int t;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   254
   int i, j, no, nc;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   255
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   256
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   257
   /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   258
   no = SDL_GetNumAudioDevices(0);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   259
   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
   260
   nc = SDL_GetNumAudioDevices(1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   261
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   262
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   263
   /* 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
   264
   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
   265
      /* Negative device index */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   266
      i = SDLTest_RandomIntegerInRange(-10,-1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   267
      name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   268
      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
   269
      SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, 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
   270
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   271
      /* Device index past range */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   272
      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
   273
         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
   274
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   275
         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
   276
         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
   277
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   278
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   279
      /* 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
   280
      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
   281
         i = no-1;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   282
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   283
         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
   284
         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
   285
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   286
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   287
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   288
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   289
}
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
/**
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
   293
 * \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
   294
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   295
 * \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
   296
 * \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
   297
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   298
int audio_printAudioDrivers()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   299
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   300
   int i, n;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   301
   const char *name;
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
   /* Get number of drivers */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   304
   n = SDL_GetNumAudioDrivers();
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   305
   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
   306
   SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
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
   /* List drivers. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   309
   if (n>0)
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   310
   {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   311
      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
   312
         name = SDL_GetAudioDriver(i);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   313
         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
   314
         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
   315
         if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   316
            SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   317
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   318
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   319
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   320
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   321
   return TEST_COMPLETED;
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
/**
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
   326
 * \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
   327
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   328
 * \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
   329
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   330
int audio_printCurrentAudioDriver()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   331
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   332
   /* Check current audio driver */
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   333
   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
   334
   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
   335
   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
   336
   if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   337
      SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   338
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   339
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   340
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   341
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   342
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   343
/* Definition of all formats, channels, and frequencies used to test audio conversions */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   344
const int _numFormats = 18;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   345
SDL_AudioFormat _formats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, 
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   346
				AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, 
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   347
                                AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   348
char *_formatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", 
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   349
				"AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", 
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   350
                                "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   351
const int _numChannels = 4;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   352
Uint8 _channels[] = { 1, 2, 4, 6 };
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   353
const int _numFrequencies = 4;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   354
int _frequencies[] = { 11025, 22050, 44100, 48000 };
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   355
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
   356
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   357
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   358
 * \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
   359
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   360
 * \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
   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
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
   363
{
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
  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
   365
  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
   366
  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
   367
  SDL_AudioSpec spec2;
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   368
  int i, ii, j, jj, k, 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
   369
  
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
  /* 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
   371
  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
   372
  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
   373
  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
   374
  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
   375
                                   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
   376
  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
   377
  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
   378
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
  /* 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
   380
  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
   381
  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
   382
  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
   383
  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
   384
  spec2.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
   385
  spec2.freq = 44100;  
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
  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
   387
                                   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
   388
  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
   389
  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
   390
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   391
  /* All source conversions with random conversion targets, allow 'null' conversions */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   392
  for (i = 0; i < _numFormats; i++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   393
    for (j = 0; j < _numChannels; j++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   394
      for (k = 0; k < _numFrequencies; k++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   395
        spec1.format = _formats[i];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   396
        spec1.channels = _channels[j];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   397
        spec1.freq = _frequencies[k];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   398
        ii = SDLTest_RandomIntegerInRange(0, _numFormats - 1);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   399
        jj = SDLTest_RandomIntegerInRange(0, _numChannels - 1);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   400
        kk = SDLTest_RandomIntegerInRange(0, _numFrequencies - 1);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   401
        spec2.format = _formats[ii];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   402
        spec2.channels = _channels[jj];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   403
        spec2.freq = _frequencies[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
   404
        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
   405
                                         spec2.format, spec2.channels, spec2.freq);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   406
        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)", 
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   407
            i, _formatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _formatsVerbose[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
   408
        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
   409
        if (result<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
   410
          SDLTest_LogError(SDL_GetError());
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   411
        } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   412
          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
   413
        }
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
      }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   415
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   416
  }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   417
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
   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
   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
 * \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
   423
 *
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
 * \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
   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
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
   427
{
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
  const char *expectedError = "Parameter 'cvt' is invalid";
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
  const char *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
   430
  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
   431
  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
   432
  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
   433
  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
   434
  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
   435
  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
   436
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
  /* Valid format */  
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
  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
   439
  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
   440
  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
   441
  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
   442
  spec2.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
   443
  spec2.freq = 44100;  
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
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
  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
   446
  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
   447
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   448
  /* 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
   449
  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
   450
                                                   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
   451
  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(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
   452
  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
   453
  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
   454
  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
   455
  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
   456
  if (error != 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
   457
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 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
   458
          "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
   459
  }
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
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
  /* 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
   462
  for (i = 1; i < 64; 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
   463
    /* Valid format to start 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
   464
    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
   465
    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
   466
    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
   467
    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
   468
    spec2.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
   469
    spec2.freq = 44100;  
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
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
    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
   472
    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
   473
   
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   474
    /* Set various invalid format inputs */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   475
    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
   476
    if (i & 1) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   477
        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
   478
        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
   479
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   480
    if (i & 2) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   481
        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
   482
        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
   483
    }
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
    if (i & 4) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   485
        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
   486
        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
   487
    }
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
    if (i & 8) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   489
        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
   490
        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
   491
    }
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
    if (i & 16) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   493
        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
   494
        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
   495
    }
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
    if (i & 32) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   497
        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
   498
        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
   499
    }
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
    SDLTest_Log(message);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   501
    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
   502
                                   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
   503
    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
   504
    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
   505
    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
   506
    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
   507
    SDLTest_AssertCheck(error != NULL && SDL_strlen(error)>0, "Validate that error message was not NULL or empty");
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
  }
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
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
  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
   511
  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
   512
                                                
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
  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
   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
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
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   517
 * \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
   518
 *
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
 * \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
   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
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
   522
{
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
   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
   524
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
   /* 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
   526
   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
   527
   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
   528
   SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
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
        "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %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
   530
        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
   531
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
   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
   533
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   534
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
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
/**
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
 * \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
   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
 * \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
   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
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
   543
{
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
   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
   545
   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
   546
   int count;
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
   char *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
   548
   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
   549
   SDL_AudioSpec desired, obtained;
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
   
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
   /* 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
   552
   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
   553
   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
   554
   if (count > 0) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   555
     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
   556
       /* 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
   557
       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
   558
       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
   559
       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
   560
       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
   561
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
       /* 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
   563
       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
   564
       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
   565
       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
   566
       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
   567
       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
   568
       desired.userdata=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
   569
       
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
       /* 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
   571
       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
   572
       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
   573
       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
   574
       if (id > 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
   575
     
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
         /* 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
   577
         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
   578
         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
   579
         SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   580
            "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %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
   581
            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
   582
         
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
         /* 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
   584
         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
   585
         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
   586
       }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   587
     }
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
   } 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
   589
     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
   590
   }
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
   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
   593
}
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
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
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   596
 * \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
   597
 *
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
 * \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
   599
 * \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
   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
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
   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
   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
   604
   int count;
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
   char *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
   606
   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
   607
   SDL_AudioSpec desired, obtained;
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
   
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
   /* 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
   610
   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
   611
   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
   612
   if (count > 0) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   613
     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
   614
       /* 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
   615
       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
   616
       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
   617
       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
   618
       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
   619
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
       /* 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
   621
       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
   622
       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
   623
       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
   624
       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
   625
       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
   626
       desired.userdata=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
   627
       
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
       /* 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
   629
       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
   630
       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
   631
       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
   632
       if (id > 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
   633
         /* 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
   634
         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
   635
         SDLTest_AssertPass("SDL_LockAudioDevice(%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
   636
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   637
         /* 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
   638
         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
   639
         SDLTest_Log("Simulate callback processing - delay");
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
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   641
         /* Unlock 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
   642
         SDL_UnlockAudioDevice(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
   643
         SDLTest_AssertPass("SDL_UnlockAudioDevice(%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
   644
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   645
         /* 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
   646
         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
   647
         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
   648
       }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   649
     }
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
   } 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
   651
     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
   652
   }
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
   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
   655
}
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
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
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   658
/**
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   659
 * \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
   660
 *
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   661
 * \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
   662
 * \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
   663
 */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   664
int audio_convertAudio()
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
  int result;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   667
  SDL_AudioCVT  cvt;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   668
  SDL_AudioSpec spec1;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   669
  SDL_AudioSpec spec2;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   670
  int c;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   671
  char message[128];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   672
  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
   673
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   674
  /* 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
   675
  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
   676
    SDL_strlcpy(message, "Changing:", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   677
    if (c & 1) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   678
      SDL_strlcat(message, " Format", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   679
    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   680
    if (c & 2) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   681
      SDL_strlcat(message, " Channels", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   682
    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   683
    if (c & 4) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   684
      SDL_strlcat(message, " Frequencies", 128);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   685
    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   686
    SDLTest_Log(message);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   687
    /* All source conversions with random conversion targets */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   688
    for (i = 0; i < _numFormats; i++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   689
      for (j = 0; j < _numChannels; j++) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   690
        for (k = 0; k < _numFrequencies; k++) {        
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   691
          spec1.format = _formats[i];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   692
          spec1.channels = _channels[j];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   693
          spec1.freq = _frequencies[k];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   694
        
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   695
          /* 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
   696
          do {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   697
            if (c & 1) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   698
              ii = SDLTest_RandomIntegerInRange(0, _numFormats - 1);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   699
            } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   700
              ii = 1;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   701
            }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   702
            if (c & 2) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   703
              jj = SDLTest_RandomIntegerInRange(0, _numChannels - 1);
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
              jj= j;
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 & 4) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   708
              kk = SDLTest_RandomIntegerInRange(0, _numFrequencies - 1);
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
              kk = k;
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
          } while ((i == ii) && (j == jj) && (k == kk));
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   713
          spec2.format = _formats[ii];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   714
          spec2.channels = _channels[jj];
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   715
          spec2.freq = _frequencies[kk];
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
          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
   718
                                           spec2.format, spec2.channels, spec2.freq);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   719
          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)", 
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   720
            i, _formatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _formatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   721
          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
   722
          if (result != 1) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   723
            SDLTest_LogError(SDL_GetError());
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   724
          } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   725
            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
   726
            if (cvt.len_mult < 1) return TEST_ABORTED;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   727
          
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   728
            /* 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
   729
            l = 64;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   730
            ll = l * cvt.len_mult;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   731
            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
   732
            cvt.len = l;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   733
            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
   734
            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
   735
            if (cvt.buf == NULL) return TEST_ABORTED;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   736
          
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   737
            /* Convert the data */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   738
            result = SDL_ConvertAudio(&cvt);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   739
            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
   740
            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
   741
            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
   742
            SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   743
          
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   744
            /* Free converted buffer */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   745
            if (cvt.buf != NULL) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   746
          	SDL_free(cvt.buf);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   747
          	cvt.buf = NULL;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   748
	    }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   749
	  }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   750
        }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   751
      }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   752
    }
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
   return TEST_COMPLETED;
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
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
 * \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
   761
 *
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   762
 * \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
   763
 */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   764
int audio_openCloseAudioDeviceConnected()
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   765
{
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
   766
   int result = -1;
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   767
   int i;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   768
   int count;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   769
   char *device;   
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   770
   SDL_AudioDeviceID id;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   771
   SDL_AudioSpec desired, obtained;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   772
   
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   773
   /* Get number of devices. */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   774
   count = SDL_GetNumAudioDevices(0);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   775
   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
   776
   if (count > 0) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   777
     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
   778
       /* Get device name */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   779
       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
   780
       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
   781
       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
   782
       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
   783
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   784
       /* Set standard desired spec */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   785
       desired.freq=22050;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   786
       desired.format=AUDIO_S16SYS;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   787
       desired.channels=2;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   788
       desired.samples=4096;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   789
       desired.callback=_audio_testCallback;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   790
       desired.userdata=NULL;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   791
       
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   792
       /* Open device */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   793
       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
   794
       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
   795
       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
   796
       if (id > 1) {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   797
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   798
/* 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
   799
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   800
#ifdef AUDIODEVICECONNECTED_DEFINED     
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   801
         /* Get connected status */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   802
         result = SDL_AudioDeviceConnected(id);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   803
         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
   804
#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
   805
         SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result);
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   806
         
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   807
         /* Close device again */
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   808
         SDL_CloseAudioDevice(id);
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   809
         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
   810
       }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   811
     }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   812
   } else {
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   813
     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
   814
   }
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   815
   
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   816
   return TEST_COMPLETED;
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   817
}
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   818
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   819
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
   820
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   821
/* ================= Test Case References ================== */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   822
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   823
/* Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   824
static const SDLTest_TestCaseReference audioTest1 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   825
		{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   826
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   827
static const SDLTest_TestCaseReference audioTest2 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   828
		{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
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 audioTest3 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   831
		{ (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
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 audioTest4 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   834
		{ (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   835
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
   836
static const SDLTest_TestCaseReference audioTest5 =
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   837
		{ (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED };
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   838
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 audioTest6 =
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   840
		{ (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED };
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 audioTest7 =
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   843
		{ (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED };
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 audioTest8 =
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   846
		{ (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED };
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 audioTest9 =
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   849
		{ (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED };
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
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   851
/* 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
   852
/* 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
   853
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   854
static const SDLTest_TestCaseReference audioTest10 =
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   855
		{ (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED };
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
/* 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
   858
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   859
static const SDLTest_TestCaseReference audioTest11 =
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   860
		{ (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED };
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   861
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   862
static const SDLTest_TestCaseReference audioTest12 =
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   863
		{ (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED };
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   864
7094
330d3bb2476d Disable one test that crashes audio suite when run together with other tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7093
diff changeset
   865
/* TODO: enable when bugs 1343 and 1396 are fixed.                                          */
330d3bb2476d Disable one test that crashes audio suite when run together with other tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7093
diff changeset
   866
/* For debugging, test case can be run manually using --filter audio_initQuitAudio */
330d3bb2476d Disable one test that crashes audio suite when run together with other tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7093
diff changeset
   867
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   868
static const SDLTest_TestCaseReference audioTest13 =
7094
330d3bb2476d Disable one test that crashes audio suite when run together with other tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7093
diff changeset
   869
		{ (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_DISABLED };
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
/* TODO: enable when bugs 1343 and 1396 are fixed.                                          */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   872
/* For debugging, test case can be run manually using --filter audio_initOpenCloseQuitAudio */
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   873
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   874
static const SDLTest_TestCaseReference audioTest14 =
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   875
		{ (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_DISABLED };
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   876
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   877
/* Sequence of Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   878
static const SDLTest_TestCaseReference *audioTests[] =  {
6830
0cd3e2e9b2c5 Add tests to audio suite; update harness filter logic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   879
	&audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6, 
7093
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   880
	&audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11, 
f0ede46d5ee7 Add tests to audio suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6897
diff changeset
   881
	&audioTest12, &audioTest13, &audioTest14, NULL
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   882
};
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   883
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   884
/* Audio test suite (global) */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   885
SDLTest_TestSuiteReference audioTestSuite = {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   886
	"Audio",
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   887
	_audioSetUp,
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   888
	audioTests,
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   889
	NULL
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   890
};