test/testautomation_audio.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Thu, 24 Jan 2013 07:58:59 -0800
changeset 6822 18f6818ba281
parent 6821 f36771112651
child 6830 0cd3e2e9b2c5
permissions -rw-r--r--
Add mouse tests; update test suites
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
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
/* Test case functions */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
 * \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
    33
 * 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
 * \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
    35
 * \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
    36
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
int audio_enumerateAndNameAudioDevices()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
   int t, tt;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
   int i, n, nn;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
   const char *name, *nameAgain;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
   /* 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
    44
   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
    45
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
      /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
      n = SDL_GetNumAudioDevices(t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
      SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
      SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "output" : "capture", n);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
      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
    51
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
      /* Variation of non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
      if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
         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
    55
         nn = SDL_GetNumAudioDevices(tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
         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
    57
         nn = SDL_GetNumAudioDevices(-tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
         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
    59
      } 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
      /* List devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
      if (n>0) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
         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
    64
            name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
            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
    66
            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
    67
            if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
              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
    69
              if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
                  /* Also try non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
                  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
    72
                  nameAgain = SDL_GetAudioDeviceName(i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
                  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
    74
                  if (nameAgain != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
                    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
    76
                    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
    77
                      "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
    78
                      i, t, i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
                  }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
               }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
            }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
 * \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
    91
 * 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
 * \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
    93
 * \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
    94
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
int audio_enumerateAndNameAudioDevicesNegativeTests()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
   int t;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
   int i, j, no, nc;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
   /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
   no = SDL_GetNumAudioDevices(0);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
   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
   104
   nc = SDL_GetNumAudioDevices(1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
   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
   106
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
   /* 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
   108
   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
   109
      /* Negative device index */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
      i = SDLTest_RandomIntegerInRange(-10,-1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
      name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
      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
   113
      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
   114
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
      /* Device index past range */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
      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
   117
         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
   118
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
         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
   120
         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
   121
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   122
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   123
      /* 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
   124
      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
   125
         i = no-1;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   127
         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
   128
         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
   129
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   130
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   135
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
/**
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
   137
 * \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
   138
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   139
 * \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
   140
 * \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
   141
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   142
int audio_printAudioDrivers()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   143
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   144
   int i, n;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   146
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   147
   /* Get number of drivers */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
   n = SDL_GetNumAudioDrivers();
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
   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
   150
   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
   151
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   152
   /* List drivers. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   153
   if (n>0)
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   154
   {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   155
      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
   156
         name = SDL_GetAudioDriver(i);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
         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
   158
         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
   159
         if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   160
            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
   161
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   162
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   164
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   165
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   166
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   167
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   168
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   169
/**
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
   170
 * \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
   171
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   172
 * \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
   173
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   174
int audio_printCurrentAudioDriver()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   175
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   176
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   177
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   178
   /* Check current audio driver */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   179
   name = SDL_GetCurrentAudioDriver();
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   180
   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
   181
   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
   182
   if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   183
      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
   184
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   185
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   186
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   187
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   188
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
   189
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   190
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   191
 * \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
   192
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   193
 * \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
   194
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   195
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
   196
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   197
  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
   198
  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
   199
  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
   200
  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
   201
  int i, j, k;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   202
  const int numFormats = 18;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   203
  SDL_AudioFormat formats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, 
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   204
                                AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, 
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   205
                                AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   206
  const int numChannels = 4;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   207
  Uint8 channels[] = { 1, 2, 4, 6 };
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   208
  const int numFrequencies = 4;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   209
  int frequencies[] = { 11025, 22050, 44100, 48000 };
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   210
  
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   211
  /* 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
   212
  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
   213
  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
   214
  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
   215
  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
   216
                                   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
   217
  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
   218
  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
   219
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   220
  /* 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
   221
  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
   222
  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
   223
  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
   224
  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
   225
  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
   226
  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
   227
  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
   228
                                   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
   229
  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
   230
  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
   231
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   232
  /* All source conversions with random conversion targets */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   233
  for (i=0; i<numFormats; 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
   234
    for (j=0; j<numChannels; j++) {
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   235
      for (k=0; k<numFrequencies; k++) {
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   236
        spec1.format = formats[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
   237
        spec1.channels = channels[j];
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   238
        spec1.freq = frequencies[k];
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   239
        spec2.format = formats[SDLTest_RandomIntegerInRange(0, numFormats - 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
   240
        spec2.channels = channels[SDLTest_RandomIntegerInRange(0, numChannels - 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
   241
        spec2.freq = frequencies[SDLTest_RandomIntegerInRange(0, numFrequencies - 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
   242
        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
   243
                                        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
   244
        SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format=%i,channels=%i,freq=%i ==> format=%i,channels=%i,freq=%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
   245
            spec1.format, spec1.channels, spec1.freq, 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
   246
        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
   247
        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
   248
          SDLTest_LogError(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
   249
        }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   250
      }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   251
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   252
  }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   253
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   254
   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
   255
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   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
   257
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   258
 * \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
   259
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   260
 * \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
   261
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   262
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
   263
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   264
  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
   265
  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
   266
  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
   267
  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
   268
  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
   269
  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
   270
  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
   271
  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
   272
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   273
  /* 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
   274
  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
   275
  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
   276
  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
   277
  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
   278
  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
   279
  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
   280
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   281
  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
   282
  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
   283
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   284
  /* 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
   285
  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
   286
                                                   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
   287
  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
   288
  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
   289
  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
   290
  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
   291
  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
   292
  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
   293
      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
   294
          "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
   295
  }
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
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   297
  /* 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
   298
  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
   299
    /* 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
   300
    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
   301
    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
   302
    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
   303
    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
   304
    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
   305
    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
   306
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   307
    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
   308
    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
   309
   
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   310
    /* Set various invalid format inputs */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   311
    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
   312
    if (i & 1) {
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   313
        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
   314
        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
   315
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   316
    if (i & 2) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   317
        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
   318
        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
   319
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   320
    if (i & 4) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   321
        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
   322
        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
   323
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   324
    if (i & 8) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   325
        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
   326
        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
   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
    if (i & 16) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   329
        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
   330
        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
   331
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   332
    if (i & 32) { 
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   333
        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
   334
        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
   335
    }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   336
    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
   337
    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
   338
                                   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
   339
    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
   340
    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
   341
    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
   342
    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
   343
    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
   344
  }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   345
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   346
  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
   347
  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
   348
                                                
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   349
  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
   350
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   351
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   352
/**
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   353
 * \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
   354
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   355
 * \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
   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
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
   358
{
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
   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
   360
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
   /* 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
   362
   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
   363
   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
   364
   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
   365
        "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
   366
        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
   367
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   368
   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
   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
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
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
/* Test callback function */
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
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
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
{
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
}
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
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
/**
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
 * \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
   379
 *
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
 * \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
   381
 */
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
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
   383
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   384
   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
   385
   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
   386
   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
   387
   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
   388
   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
   389
   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
   390
   
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   391
   /* 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
   392
   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
   393
   SDLTest_AssertPass("Call to 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
   394
   if (count>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
   395
     for (i=0; i< count; 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
   396
       /* 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
   397
       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
   398
       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
   399
       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
   400
       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
   401
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   402
       /* 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
   403
       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
   404
       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
   405
       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
   406
       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
   407
       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
   408
       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
   409
       
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
       /* 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
   411
       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
   412
       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
   413
       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
   414
       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
   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
         /* 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
   417
         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
   418
         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
   419
         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
   420
            "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
   421
            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
   422
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   423
         /* 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
   424
         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
   425
         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
   426
       }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   427
     }
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
   } 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
   429
     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
   430
   }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   431
   
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
   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
   433
}
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
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
/**
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
 * \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
   437
 *
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
 * \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
   439
 * \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
   440
 */
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
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
   442
{
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
   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
   444
   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
   445
   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
   446
   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
   447
   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
   448
   
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
   /* 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
   450
   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
   451
   SDLTest_AssertPass("Call to 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
   452
   if (count>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
   453
     for (i=0; i< count; 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
   454
       /* 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
   455
       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
   456
       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
   457
       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
   458
       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
   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
       /* 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
   461
       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
   462
       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
   463
       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
   464
       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
   465
       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
   466
       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
   467
       
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
       /* 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
   469
       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
   470
       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
   471
       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
   472
       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
   473
         /* 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
   474
         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
   475
         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
   476
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   477
         /* 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
   478
         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
   479
         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
   480
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   481
         /* 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
   482
         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
   483
         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
   484
         
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   485
         /* 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
   486
         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
   487
         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
   488
       }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   489
     }
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
   } 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
   491
     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
   492
   }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   493
   
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
   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
   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
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   497
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
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   499
/* ================= Test Case References ================== */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   500
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   501
/* Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   502
static const SDLTest_TestCaseReference audioTest1 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   503
		{ (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
   504
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   505
static const SDLTest_TestCaseReference audioTest2 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   506
		{ (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
   507
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   508
static const SDLTest_TestCaseReference audioTest3 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   509
		{ (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
   510
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   511
static const SDLTest_TestCaseReference audioTest4 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   512
		{ (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
   513
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
   514
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
   515
		{ (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
   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
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
   518
		{ (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
   519
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   520
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
   521
		{ (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
   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
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
   524
		{ (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
   525
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6772
diff changeset
   526
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
   527
		{ (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
   528
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   529
/* Sequence of Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   530
static const SDLTest_TestCaseReference *audioTests[] =  {
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
   531
	&audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6, &audioTest7, &audioTest8, &audioTest9, NULL
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   532
};
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   533
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   534
/* Audio test suite (global) */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   535
SDLTest_TestSuiteReference audioTestSuite = {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   536
	"Audio",
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   537
	_audioSetUp,
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   538
	audioTests,
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   539
	NULL
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   540
};