test/automated/testsdl.c
changeset 3541 0c429a5fda8a
parent 3482 78db4f7ae2f3
child 3596 f638ded38b8a
     1.1 --- a/test/automated/testsdl.c	Fri Dec 11 09:13:51 2009 +0000
     1.2 +++ b/test/automated/testsdl.c	Fri Dec 11 09:22:34 2009 +0000
     1.3 @@ -12,6 +12,7 @@
     1.4  
     1.5  #include "platform/platform.h"
     1.6  #include "rwops/rwops.h"
     1.7 +#include "rect/rect.h"
     1.8  #include "surface/surface.h"
     1.9  #include "render/render.h"
    1.10  #include "audio/audio.h"
    1.11 @@ -41,6 +42,7 @@
    1.12  /* Automatic. */
    1.13  static int run_platform    = 1; /**< Run platform tests. */
    1.14  static int run_rwops       = 1; /**< Run RWops tests. */
    1.15 +static int run_rect        = 1; /**< Run rect tests. */
    1.16  static int run_surface     = 1; /**< Run surface tests. */
    1.17  static int run_render      = 1; /**< Run render tests. */
    1.18  static int run_audio       = 1; /**< Run audio tests. */
    1.19 @@ -55,206 +57,75 @@
    1.20  /**
    1.21   * @brief Displays program usage.
    1.22   */
    1.23 -#ifdef NO_GETOPT
    1.24 -static void print_usage( const char *name )
    1.25 -{
    1.26 -}
    1.27 -#else
    1.28 -#if !defined(NO_GETOPT_LONG)
    1.29  static void print_usage( const char *name )
    1.30  {
    1.31     printf("Usage: %s [OPTIONS]\n", name);
    1.32     printf("Options are:\n");
    1.33     printf("   -m, --manual        enables tests that require user interaction\n");
    1.34 -   printf("   -p, --noplatform    do not run the platform tests\n");
    1.35 -   printf("   -o, --norwops       do not run the rwops tests\n");
    1.36 -   printf("   -s, --nosurface     do not run the surface tests\n");
    1.37 -   printf("   -r, --norender      do not run the render tests\n");
    1.38 -   printf("   -a, --noaudio       do not run the audio tests\n");
    1.39 +   printf("   --noplatform        do not run the platform tests\n");
    1.40 +   printf("   --norwops           do not run the rwops tests\n");
    1.41 +   printf("   --norect            do not run the rect tests\n");
    1.42 +   printf("   --nosurface         do not run the surface tests\n");
    1.43 +   printf("   --norender          do not run the render tests\n");
    1.44 +   printf("   --noaudio           do not run the audio tests\n");
    1.45     printf("   -v, --verbose       increases verbosity level by 1 for each -v\n");
    1.46     printf("   -q, --quiet         only displays errors\n");
    1.47     printf("   -h, --help          display this message and exit\n");
    1.48  }
    1.49 -#endif /* !NO_GETOPT_LONG */
    1.50 -
    1.51 -#if defined(NO_GETOPT_LONG)
    1.52 -static void print_usage( const char *name )
    1.53 -{
    1.54 -   printf("Usage: %s [OPTIONS]\n", name);
    1.55 -   printf("Options are:\n");
    1.56 -   printf("   -m,     enables tests that require user interaction\n");
    1.57 -   printf("   -p,     do not run the platform tests\n");
    1.58 -   printf("   -o,     do not run the rwops tests\n");
    1.59 -   printf("   -s,     do not run the surface tests\n");
    1.60 -   printf("   -r,     do not run the render tests\n");
    1.61 -   printf("   -a,     do not run the audio tests\n");
    1.62 -   printf("   -v,     increases verbosity level by 1 for each -v\n");
    1.63 -   printf("   -q,     only displays errors\n");
    1.64 -   printf("   -h,     display this message and exit\n");
    1.65 -}
    1.66 -#endif /* NO_GETOPT_LONG */
    1.67 -#endif /* NO_GETOPT */
    1.68  
    1.69  /**
    1.70   * @brief Handles the options.
    1.71   */
    1.72 -#ifdef NO_GETOPT
    1.73  static void parse_options( int argc, char *argv[] )
    1.74  {
    1.75 -}
    1.76 -#else
    1.77 -#if !defined(NO_GETOPT_LONG)
    1.78 -static void parse_options( int argc, char *argv[] )
    1.79 -{
    1.80 -   static struct option long_options[] = {
    1.81 -      { "manual", no_argument, 0, 'm' },
    1.82 -      { "noplatform", no_argument, 0, 'p' },
    1.83 -      { "norwops", no_argument, 0, 'o' },
    1.84 -      { "nosurface", no_argument, 0, 's' },
    1.85 -      { "norender", no_argument, 0, 'r' },
    1.86 -      { "noaudio", no_argument, 0, 'a' },
    1.87 -      { "verbose", no_argument, 0, 'v' },
    1.88 -      { "quiet", no_argument, 0, 'q' },
    1.89 -      { "help", no_argument, 0, 'h' },
    1.90 -      {NULL,0,0,0}
    1.91 -   };
    1.92 -   int option_index = 0;
    1.93 -   int c = 0;
    1.94     int i;
    1.95 -   const char *str;
    1.96  
    1.97 -   /* Iterate over options. */
    1.98 -   while ((c = getopt_long( argc, argv,
    1.99 -               "mposravqh",
   1.100 -               long_options, &option_index)) != -1) {
   1.101 +   for (i = 1; i < argc; ++i) {
   1.102 +      const char *arg = argv[i];
   1.103 +      if (SDL_strcmp(arg, "-m") == 0 || SDL_strcmp(arg, "--manual") == 0) {
   1.104 +         run_manual = 1;
   1.105 +         continue;
   1.106 +      }
   1.107 +      if (SDL_strcmp(arg, "-v") == 0 || SDL_strcmp(arg, "--verbose") == 0) {
   1.108 +         int level;
   1.109 +         SDL_ATgeti( SDL_AT_VERBOSE, &level );
   1.110 +         SDL_ATseti( SDL_AT_VERBOSE, level+1 );
   1.111 +         continue;
   1.112 +      }
   1.113 +      if (SDL_strcmp(arg, "-q") == 0 || SDL_strcmp(arg, "--quiet") == 0) {
   1.114 +         SDL_ATseti( SDL_AT_QUIET, 1 );
   1.115 +         continue;
   1.116 +      }
   1.117 +      if (SDL_strcmp(arg, "--noplatform") == 0) {
   1.118 +         run_platform = 0;
   1.119 +         continue;
   1.120 +      }
   1.121 +      if (SDL_strcmp(arg, "--norwops") == 0) {
   1.122 +         run_rwops = 0;
   1.123 +         continue;
   1.124 +      }
   1.125 +      if (SDL_strcmp(arg, "--norect") == 0) {
   1.126 +         run_rect = 0;
   1.127 +         continue;
   1.128 +      }
   1.129 +      if (SDL_strcmp(arg, "--nosurface") == 0) {
   1.130 +         run_surface = 0;
   1.131 +         continue;
   1.132 +      }
   1.133 +      if (SDL_strcmp(arg, "--norender") == 0) {
   1.134 +         run_render = 0;
   1.135 +         continue;
   1.136 +      }
   1.137 +      if (SDL_strcmp(arg, "--noaudio") == 0) {
   1.138 +         run_audio = 0;
   1.139 +         continue;
   1.140 +      }
   1.141  
   1.142 -      /* Handle options. */
   1.143 -      switch (c) {
   1.144 -         case 0:
   1.145 -            str = long_options[option_index].name;
   1.146 -            if (strcmp(str,"noplatform")==0)
   1.147 -               run_platform = 0;
   1.148 -            else if (strcmp(str,"norwops")==0)
   1.149 -               run_rwops = 0;
   1.150 -            else if (strcmp(str,"nosurface")==0)
   1.151 -               run_surface = 0;
   1.152 -            else if (strcmp(str,"norender")==0)
   1.153 -               run_render = 0;
   1.154 -            else if (strcmp(str,"noaudio")==0)
   1.155 -               run_audio = 0;
   1.156 -            break;
   1.157 -
   1.158 -         /* Manual. */
   1.159 -         case 'm':
   1.160 -            run_manual = 1;
   1.161 -            break;
   1.162 -
   1.163 -         /* No platform. */
   1.164 -         case 'p':
   1.165 -            run_platform = 0;
   1.166 -            break;
   1.167 -
   1.168 -         /* No rwops. */
   1.169 -         case 'o':
   1.170 -            run_rwops = 0;
   1.171 -            break;
   1.172 -
   1.173 -         /* No surface. */
   1.174 -         case 's':
   1.175 -            run_surface = 0;
   1.176 -            break;
   1.177 -
   1.178 -         /* No render. */
   1.179 -         case 'r':
   1.180 -            run_render = 0;
   1.181 -            break;
   1.182 -
   1.183 -         /* No audio. */
   1.184 -         case 'a':
   1.185 -            run_audio = 0;
   1.186 -            break;
   1.187 -
   1.188 -         /* Verbosity. */
   1.189 -         case 'v':
   1.190 -            SDL_ATgeti( SDL_AT_VERBOSE, &i );
   1.191 -            SDL_ATseti( SDL_AT_VERBOSE, i+1 );
   1.192 -            break;
   1.193 -
   1.194 -         /* Quiet. */
   1.195 -         case 'q':
   1.196 -            SDL_ATseti( SDL_AT_QUIET, 1 );
   1.197 -            break;
   1.198 -
   1.199 -         /* Help. */
   1.200 -         case 'h':
   1.201 -            print_usage( argv[0] );
   1.202 -            exit(EXIT_SUCCESS);
   1.203 -      }
   1.204 +      /* Print help and exit! */
   1.205 +      print_usage( argv[0] );
   1.206 +      exit(EXIT_FAILURE);
   1.207     }
   1.208  }
   1.209 -#endif /* !NO_GETOPT_LONG */
   1.210 -
   1.211 -#if defined(NO_GETOPT_LONG)
   1.212 -static void parse_options( int argc, char *argv[] )
   1.213 -{
   1.214 -   static char* short_options="mposravqh";
   1.215 -   int c = 0;
   1.216 -   int i;
   1.217 -
   1.218 -   /* Iterate over options. */
   1.219 -   while ((c = getopt(argc, argv, short_options)) != -1) {
   1.220 -      /* Handle options. */
   1.221 -      switch (c) {
   1.222 -         /* Manual. */
   1.223 -         case 'm':
   1.224 -            run_manual = 1;
   1.225 -            break;
   1.226 -
   1.227 -         /* No platform. */
   1.228 -         case 'p':
   1.229 -            run_platform = 0;
   1.230 -            break;
   1.231 -
   1.232 -         /* No rwops. */
   1.233 -         case 'o':
   1.234 -            run_rwops = 0;
   1.235 -            break;
   1.236 -
   1.237 -         /* No surface. */
   1.238 -         case 's':
   1.239 -            run_surface = 0;
   1.240 -            break;
   1.241 -
   1.242 -         /* No render. */
   1.243 -         case 'r':
   1.244 -            run_render = 0;
   1.245 -            break;
   1.246 -
   1.247 -         /* No audio. */
   1.248 -         case 'a':
   1.249 -            run_audio = 0;
   1.250 -            break;
   1.251 -
   1.252 -         /* Verbosity. */
   1.253 -         case 'v':
   1.254 -            SDL_ATgeti( SDL_AT_VERBOSE, &i );
   1.255 -            SDL_ATseti( SDL_AT_VERBOSE, i+1 );
   1.256 -            break;
   1.257 -
   1.258 -         /* Quiet. */
   1.259 -         case 'q':
   1.260 -            SDL_ATseti( SDL_AT_QUIET, 1 );
   1.261 -            break;
   1.262 -
   1.263 -         /* Help. */
   1.264 -         case 'h':
   1.265 -            print_usage( argv[0] );
   1.266 -            exit(EXIT_SUCCESS);
   1.267 -      }
   1.268 -   }
   1.269 -}
   1.270 -#endif /* NO_GETOPT_LONG */
   1.271 -#endif /* NO_GETOPT */
   1.272  
   1.273  /**
   1.274   * @brief Main entry point.
   1.275 @@ -282,6 +153,8 @@
   1.276        failed += test_platform();
   1.277     if (run_rwops)
   1.278        failed += test_rwops();
   1.279 +   if (run_rect)
   1.280 +      failed += test_rect();
   1.281     if (run_surface)
   1.282        failed += test_surface();
   1.283     if (run_render)