Blame vector/test.c

Packit 67cb25
/* vector/test.c
Packit 67cb25
 * 
Packit 67cb25
 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
Packit 67cb25
 * 
Packit 67cb25
 * This program is free software; you can redistribute it and/or modify
Packit 67cb25
 * it under the terms of the GNU General Public License as published by
Packit 67cb25
 * the Free Software Foundation; either version 3 of the License, or (at
Packit 67cb25
 * your option) any later version.
Packit 67cb25
 * 
Packit 67cb25
 * This program is distributed in the hope that it will be useful, but
Packit 67cb25
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 67cb25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 67cb25
 * General Public License for more details.
Packit 67cb25
 * 
Packit 67cb25
 * You should have received a copy of the GNU General Public License
Packit 67cb25
 * along with this program; if not, write to the Free Software
Packit 67cb25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 67cb25
 */
Packit 67cb25
Packit 67cb25
#include <config.h>
Packit 67cb25
Packit 67cb25
#if defined( _MSC_VER ) && defined( GSL_DLL )
Packit 67cb25
#undef inline
Packit 67cb25
#define inline __forceinline 
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
#if (!GSL_RANGE_CHECK) && defined(HAVE_INLINE)
Packit 67cb25
#undef GSL_RANGE_CHECK
Packit 67cb25
#define GSL_RANGE_CHECK 1
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
#include <stdlib.h>
Packit 67cb25
#include <unistd.h>
Packit 67cb25
#include <fcntl.h>
Packit 67cb25
#include <stdio.h>
Packit 67cb25
#include <gsl/gsl_math.h>
Packit 67cb25
#include <gsl/gsl_vector.h>
Packit 67cb25
#include <gsl/gsl_test.h>
Packit 67cb25
#include <gsl/gsl_ieee_utils.h>
Packit 67cb25
Packit 67cb25
int status = 0;
Packit 67cb25
Packit 67cb25
#ifndef DESC
Packit 67cb25
#define DESC ""
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
#define BASE_GSL_COMPLEX_LONG
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_complex_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_GSL_COMPLEX_LONG
Packit 67cb25
Packit 67cb25
#define BASE_GSL_COMPLEX
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_complex_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_GSL_COMPLEX
Packit 67cb25
Packit 67cb25
#define BASE_GSL_COMPLEX_FLOAT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_complex_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_GSL_COMPLEX_FLOAT
Packit 67cb25
Packit 67cb25
#define BASE_LONG_DOUBLE
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_LONG_DOUBLE
Packit 67cb25
Packit 67cb25
#define BASE_DOUBLE
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_DOUBLE
Packit 67cb25
Packit 67cb25
#define BASE_FLOAT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_FLOAT
Packit 67cb25
Packit 67cb25
#define BASE_ULONG
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_ULONG
Packit 67cb25
Packit 67cb25
#define BASE_LONG
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_LONG
Packit 67cb25
Packit 67cb25
#define BASE_UINT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_UINT
Packit 67cb25
Packit 67cb25
#define BASE_INT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_INT
Packit 67cb25
Packit 67cb25
#define BASE_USHORT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_USHORT
Packit 67cb25
Packit 67cb25
#define BASE_SHORT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_SHORT
Packit 67cb25
Packit 67cb25
#define BASE_UCHAR
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_UCHAR
Packit 67cb25
Packit 67cb25
#define BASE_CHAR
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_CHAR
Packit 67cb25
Packit 67cb25
void my_error_handler (const char *reason, const char *file,
Packit 67cb25
                       int line, int err);
Packit 67cb25
Packit 67cb25
int
Packit 67cb25
main (void)
Packit 67cb25
{
Packit 67cb25
  size_t stride, ostride, N;
Packit 67cb25
Packit 67cb25
  gsl_ieee_env_setup ();
Packit 67cb25
Packit 67cb25
  for (N = 10; N < 1024; N = 2*N + 1) 
Packit 67cb25
    {
Packit 67cb25
      for (stride = 1; stride < 5 ; stride++)
Packit 67cb25
        {
Packit 67cb25
          test_func (stride, N);
Packit 67cb25
          test_float_func (stride, N);
Packit 67cb25
          test_long_double_func (stride, N);
Packit 67cb25
          test_ulong_func (stride, N);
Packit 67cb25
          test_long_func (stride, N);
Packit 67cb25
          test_uint_func (stride, N);
Packit 67cb25
          test_int_func (stride, N);
Packit 67cb25
          test_ushort_func (stride, N);
Packit 67cb25
          test_short_func (stride, N);
Packit 67cb25
          test_uchar_func (stride, N);
Packit 67cb25
          test_char_func (stride, N);
Packit 67cb25
Packit 67cb25
          test_complex_func (stride, N);
Packit 67cb25
          test_complex_float_func (stride, N);
Packit 67cb25
          test_complex_long_double_func (stride, N);
Packit 67cb25
Packit 67cb25
          for (ostride = 1; ostride < 5 ; ostride++)
Packit 67cb25
            {
Packit 67cb25
              test_ops (stride, ostride, N);
Packit 67cb25
              test_float_ops (stride, ostride, N);
Packit 67cb25
              test_long_double_ops (stride, ostride, N);
Packit 67cb25
              test_ulong_ops (stride, ostride, N);
Packit 67cb25
              test_long_ops (stride, ostride, N);
Packit 67cb25
              test_uint_ops (stride, ostride, N);
Packit 67cb25
              test_int_ops (stride, ostride, N);
Packit 67cb25
              test_ushort_ops (stride, ostride, N);
Packit 67cb25
              test_short_ops (stride, ostride, N);
Packit 67cb25
              test_uchar_ops (stride, ostride, N);
Packit 67cb25
              test_char_ops (stride, ostride, N);
Packit 67cb25
              test_complex_ops (stride, ostride, N);
Packit 67cb25
              test_complex_float_ops (stride, ostride, N);
Packit 67cb25
              test_complex_long_double_ops (stride, ostride, N);
Packit 67cb25
            }              
Packit 67cb25
Packit 67cb25
          test_text (stride, N);
Packit 67cb25
          test_float_text (stride, N);
Packit 67cb25
#if HAVE_PRINTF_LONGDOUBLE
Packit 67cb25
          test_long_double_text (stride, N);
Packit 67cb25
#endif
Packit 67cb25
          test_ulong_text (stride, N);
Packit 67cb25
          test_long_text (stride, N);
Packit 67cb25
          test_uint_text (stride, N);
Packit 67cb25
          test_int_text (stride, N);
Packit 67cb25
          test_ushort_text (stride, N);
Packit 67cb25
          test_short_text (stride, N);
Packit 67cb25
          test_uchar_text (stride, N);
Packit 67cb25
          test_char_text (stride, N);
Packit 67cb25
Packit 67cb25
          test_complex_text (stride, N);
Packit 67cb25
          test_complex_float_text (stride, N);
Packit 67cb25
#if HAVE_PRINTF_LONGDOUBLE
Packit 67cb25
          test_complex_long_double_text (stride, N);
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
          test_file (stride, N);
Packit 67cb25
          test_float_file (stride, N);
Packit 67cb25
          test_long_double_file (stride, N);
Packit 67cb25
          test_ulong_file (stride, N);
Packit 67cb25
          test_long_file (stride, N);
Packit 67cb25
          test_uint_file (stride, N);
Packit 67cb25
          test_int_file (stride, N);
Packit 67cb25
          test_ushort_file (stride, N);
Packit 67cb25
          test_short_file (stride, N);
Packit 67cb25
          test_uchar_file (stride, N);
Packit 67cb25
          test_char_file (stride, N);
Packit 67cb25
          test_complex_file (stride, N);
Packit 67cb25
          test_complex_float_file (stride, N);
Packit 67cb25
          test_complex_long_double_file (stride, N);
Packit 67cb25
        }
Packit 67cb25
    }
Packit 67cb25
Packit 67cb25
    test_alloc_zero_length ();
Packit 67cb25
    test_float_alloc_zero_length ();
Packit 67cb25
    test_long_double_alloc_zero_length ();
Packit 67cb25
    test_ulong_alloc_zero_length ();
Packit 67cb25
    test_long_alloc_zero_length ();
Packit 67cb25
    test_uint_alloc_zero_length ();
Packit 67cb25
    test_int_alloc_zero_length ();
Packit 67cb25
    test_ushort_alloc_zero_length ();
Packit 67cb25
    test_short_alloc_zero_length ();
Packit 67cb25
    test_uchar_alloc_zero_length ();
Packit 67cb25
    test_char_alloc_zero_length ();
Packit 67cb25
Packit 67cb25
    test_complex_alloc_zero_length ();
Packit 67cb25
    test_complex_float_alloc_zero_length ();
Packit 67cb25
    test_complex_long_double_alloc_zero_length ();
Packit 67cb25
Packit 67cb25
    test_calloc_zero_length ();
Packit 67cb25
    test_float_calloc_zero_length ();
Packit 67cb25
    test_long_double_calloc_zero_length ();
Packit 67cb25
    test_ulong_calloc_zero_length ();
Packit 67cb25
    test_long_calloc_zero_length ();
Packit 67cb25
    test_uint_calloc_zero_length ();
Packit 67cb25
    test_int_calloc_zero_length ();
Packit 67cb25
    test_ushort_calloc_zero_length ();
Packit 67cb25
    test_short_calloc_zero_length ();
Packit 67cb25
    test_uchar_calloc_zero_length ();
Packit 67cb25
    test_char_calloc_zero_length ();
Packit 67cb25
Packit 67cb25
    test_complex_calloc_zero_length ();
Packit 67cb25
    test_complex_float_calloc_zero_length ();
Packit 67cb25
    test_complex_long_double_calloc_zero_length ();
Packit 67cb25
Packit 67cb25
#if GSL_RANGE_CHECK
Packit 67cb25
  gsl_set_error_handler (&my_error_handler);
Packit 67cb25
Packit 67cb25
  for (N = 1; N < 1024; N *=2) 
Packit 67cb25
    {
Packit 67cb25
      for (stride = 1; stride < 5 ; stride++)
Packit 67cb25
        {
Packit 67cb25
          test_trap (stride, N);
Packit 67cb25
          test_float_trap (stride, N);
Packit 67cb25
          test_long_double_trap (stride, N);
Packit 67cb25
          test_ulong_trap (stride, N);
Packit 67cb25
          test_long_trap (stride, N);
Packit 67cb25
          test_uint_trap (stride, N);
Packit 67cb25
          test_int_trap (stride, N);
Packit 67cb25
          test_ushort_trap (stride, N);
Packit 67cb25
          test_short_trap (stride, N);
Packit 67cb25
          test_uchar_trap (stride, N);
Packit 67cb25
          test_char_trap (stride, N);
Packit 67cb25
          test_complex_trap (stride, N);
Packit 67cb25
          test_complex_float_trap (stride, N);
Packit 67cb25
          test_complex_long_double_trap (stride, N);
Packit 67cb25
        }
Packit 67cb25
    }
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
  exit (gsl_test_summary ());
Packit 67cb25
}
Packit 67cb25
Packit 67cb25
void
Packit 67cb25
my_error_handler (const char *reason, const char *file, int line, int err)
Packit 67cb25
{
Packit 67cb25
  if (0)
Packit 67cb25
    printf ("(caught [%s:%d: %s (%d)])\n", file, line, reason, err);
Packit 67cb25
  status = 1;
Packit 67cb25
}