ArrayFactoriesTest.c

Go to the documentation of this file.
00001 /*************** <lalVerbatim file="ArrayFactoriesTestCV"> ****
00002 $Id: ArrayFactoriesTest.m4,v 1.7 2001/03/04 22:37:11 jolien Exp $
00003 **************** </lalVerbatim> *******************************/
00004 
00005 /* <lalLaTeX>
00006 
00007 \subsection{Program \texttt{ArrayFactoriesTest.c}}
00008 \label{ss:ArrayFactoriesTest.c}
00009 
00010 A program to test create/destroy array routines.
00011 
00012 \subsubsection*{Usage}
00013 \begin{verbatim}
00014 ArrayFactoriesTest [options]
00015 Options:
00016   -h         print help
00017   -q         quiet: run silently
00018   -v         verbose: print extra information
00019   -d level   set lalDebugLevel to level
00020 \end{verbatim}
00021 
00022 \subsubsection*{Description}
00023 
00024 \subsubsection*{Exit codes}
00025 \begin{tabular}{|c|l|}
00026 \hline
00027  Code & Explanation                   \\
00028 \hline
00029 \tt 0 & Success, normal exit.         \\
00030 \tt 1 & Subroutine failed.            \\
00031 \hline
00032 \end{tabular}
00033 
00034 \subsubsection*{Algorithm}
00035 
00036 \subsubsection*{Uses}
00037 \begin{verbatim}
00038 lalDebugLevel
00039 TYPECODECreateArray()
00040 TYPECODEDestroyArray()
00041 \end{verbatim}
00042 
00043 \subsubsection*{Notes}
00044 
00045 \vfill{\footnotesize\input{ArrayFactoriesTestCV}}
00046 
00047 </lalLaTeX> */
00048 
00049 #include <stdlib.h>
00050 #include <stdio.h>
00051 #include <string.h>
00052 
00053 #include <lal/LALConfig.h>
00054 
00055 #ifdef HAVE_UNISTD_H
00056 #include <unistd.h>
00057 #endif
00058 
00059 #ifdef HAVE_GETOPT_H
00060 #include <getopt.h>
00061 #endif
00062 
00063 #include <lal/LALStdlib.h>
00064 #include <lal/AVFactories.h>
00065 
00066 #define CODES_(x) #x
00067 #define CODES(x) CODES_(x)
00068 
00069 NRCSID( MAIN, "$Id: ArrayFactoriesTest.m4,v 1.7 2001/03/04 22:37:11 jolien Exp $" );
00070 
00071 extern char *optarg;
00072 extern int   optind;
00073 
00074 int lalDebugLevel = 0;
00075 int verbose    = 0;
00076 
00077 static void
00078 Usage (const char *program, int exitflag);
00079 
00080 static void
00081 ParseOptions (int argc, char *argv[]);
00082 
00083 static void
00084 TestStatus (LALStatus *status, const char *expectedCodes, int exitCode);
00085 
00086 static void
00087 ClearStatus (LALStatus *status);
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 static void ZArrayFactoriesTest ( void )
00109 {
00110   static UINT4   dims[3]    = { 1, 2, 4 };
00111   static UINT4   dbad[3]    = { 1, 0, 4 };
00112   UINT4Vector    dimLength  = { 3, dims };
00113   UINT4Vector    badLength1 = { 3, NULL };
00114   UINT4Vector    badLength2 = { 0, dims };
00115   UINT4Vector    badLength3 = { 3, dbad };
00116   static LALStatus  status;
00117   static COMPLEX16Array  *array;
00118   static COMPLEX16Array   astore;
00119   static COMPLEX16    datum;
00120 
00121 
00122   /*
00123    *
00124    * Test ordinary behavior.
00125    *
00126    */
00127 
00128 
00129   LALZCreateArray ( &status, &array, &dimLength );
00130   TestStatus( &status, CODES( 0 ), 1 );
00131 
00132   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX16 ) );
00133 
00134   /* resize up */
00135   /*
00136    * dimLength.data[0] *= 2;
00137    * dimLength.data[1] *= 3;
00138    * dimLength.data[2] *= 4;
00139   */
00140   dims[0] *= 2;
00141   dims[1] *= 3;
00142   dims[2] *= 4;
00143   LALZResizeArray ( &status, &array, &dimLength );
00144   TestStatus( &status, CODES( 0 ), 1 );
00145   
00146   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX16 ) );
00147   
00148   /* resize down */
00149   dims[0] /= 2;
00150   dims[1] /= 3;
00151   dims[2] /= 2;
00152   LALZResizeArray ( &status, &array, &dimLength );
00153   TestStatus( &status, CODES( 0 ), 1 );
00154   
00155   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX16 ) );
00156   
00157   /* resize down again */
00158   dims[2] /= 2;
00159   LALZResizeArray ( &status, &array, &dimLength );
00160   TestStatus( &status, CODES( 0 ), 1 );
00161   
00162   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX16 ) );
00163   
00164   LALZDestroyArray ( &status, &array );
00165   TestStatus( &status, CODES( 0 ), 1 );
00166 
00167   LALCheckMemoryLeaks();
00168 
00169 
00170   /*
00171    *
00172    * Test error codes.
00173    *
00174    */
00175 
00176 
00177 #ifndef LAL_NDEBUG
00178 
00179   if ( ! lalNoDebug )
00180   {
00181     LALZCreateArray ( &status, &array, &badLength1 );
00182     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00183 
00184     LALZResizeArray ( &status, &array, &badLength1 );
00185     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00186 
00187     LALZCreateArray ( &status, &array, &badLength2 );
00188     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00189 
00190     LALZResizeArray ( &status, &array, &badLength2 );
00191     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00192 
00193     LALZCreateArray ( &status, &array, &badLength3 );
00194     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00195 
00196     LALZResizeArray ( &status, &array, &badLength3 );
00197     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00198     LALCheckMemoryLeaks();
00199 
00200     LALZDestroyArray ( &status, NULL );
00201     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00202 
00203     LALZCreateArray ( &status, NULL, &dimLength );
00204     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00205 
00206     LALZResizeArray ( &status, NULL, &badLength1 );
00207     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00208 
00209     LALZDestroyArray ( &status, &array );
00210     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00211 
00212     array = &astore;
00213     LALZCreateArray ( &status, &array, &dimLength );
00214     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00215 
00216     LALZResizeArray ( &status, &array, &badLength1 );
00217     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);
00218 
00219     LALZResizeArray ( &status, &array, &badLength2 );
00220     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00221 
00222     LALZResizeArray ( &status, &array, &badLength3 );
00223     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00224 
00225     LALZDestroyArray ( &status, &array );
00226     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00227 
00228     array->data = &datum;
00229     LALZDestroyArray ( &status, &array );
00230     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00231     ClearStatus( &status );
00232   }
00233 
00234 #else
00235   array = &astore;
00236   array->data = &datum;
00237   badLength1.data = NULL;
00238   badLength2.length = 0;
00239   badLength3.data = dbad;
00240 #endif
00241 
00242   LALCheckMemoryLeaks();
00243   printf( "PASS: tests of LALZCreateArray, LALZResizeArray, and LALZDestroyArray \n" );
00244           
00245   return;
00246 }
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 static void CArrayFactoriesTest ( void )
00269 {
00270   static UINT4   dims[3]    = { 1, 2, 4 };
00271   static UINT4   dbad[3]    = { 1, 0, 4 };
00272   UINT4Vector    dimLength  = { 3, dims };
00273   UINT4Vector    badLength1 = { 3, NULL };
00274   UINT4Vector    badLength2 = { 0, dims };
00275   UINT4Vector    badLength3 = { 3, dbad };
00276   static LALStatus  status;
00277   static COMPLEX8Array  *array;
00278   static COMPLEX8Array   astore;
00279   static COMPLEX8    datum;
00280 
00281 
00282   /*
00283    *
00284    * Test ordinary behavior.
00285    *
00286    */
00287 
00288 
00289   LALCCreateArray ( &status, &array, &dimLength );
00290   TestStatus( &status, CODES( 0 ), 1 );
00291 
00292   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX8 ) );
00293 
00294   /* resize up */
00295   /*
00296    * dimLength.data[0] *= 2;
00297    * dimLength.data[1] *= 3;
00298    * dimLength.data[2] *= 4;
00299   */
00300   dims[0] *= 2;
00301   dims[1] *= 3;
00302   dims[2] *= 4;
00303   LALCResizeArray ( &status, &array, &dimLength );
00304   TestStatus( &status, CODES( 0 ), 1 );
00305   
00306   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX8 ) );
00307   
00308   /* resize down */
00309   dims[0] /= 2;
00310   dims[1] /= 3;
00311   dims[2] /= 2;
00312   LALCResizeArray ( &status, &array, &dimLength );
00313   TestStatus( &status, CODES( 0 ), 1 );
00314   
00315   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX8 ) );
00316   
00317   /* resize down again */
00318   dims[2] /= 2;
00319   LALCResizeArray ( &status, &array, &dimLength );
00320   TestStatus( &status, CODES( 0 ), 1 );
00321   
00322   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( COMPLEX8 ) );
00323   
00324   LALCDestroyArray ( &status, &array );
00325   TestStatus( &status, CODES( 0 ), 1 );
00326 
00327   LALCheckMemoryLeaks();
00328 
00329 
00330   /*
00331    *
00332    * Test error codes.
00333    *
00334    */
00335 
00336 
00337 #ifndef LAL_NDEBUG
00338 
00339   if ( ! lalNoDebug )
00340   {
00341     LALCCreateArray ( &status, &array, &badLength1 );
00342     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00343 
00344     LALCResizeArray ( &status, &array, &badLength1 );
00345     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00346 
00347     LALCCreateArray ( &status, &array, &badLength2 );
00348     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00349 
00350     LALCResizeArray ( &status, &array, &badLength2 );
00351     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00352 
00353     LALCCreateArray ( &status, &array, &badLength3 );
00354     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00355 
00356     LALCResizeArray ( &status, &array, &badLength3 );
00357     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00358     LALCheckMemoryLeaks();
00359 
00360     LALCDestroyArray ( &status, NULL );
00361     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00362 
00363     LALCCreateArray ( &status, NULL, &dimLength );
00364     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00365 
00366     LALCResizeArray ( &status, NULL, &badLength1 );
00367     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00368 
00369     LALCDestroyArray ( &status, &array );
00370     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00371 
00372     array = &astore;
00373     LALCCreateArray ( &status, &array, &dimLength );
00374     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00375 
00376     LALCResizeArray ( &status, &array, &badLength1 );
00377     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);
00378 
00379     LALCResizeArray ( &status, &array, &badLength2 );
00380     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00381 
00382     LALCResizeArray ( &status, &array, &badLength3 );
00383     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00384 
00385     LALCDestroyArray ( &status, &array );
00386     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00387 
00388     array->data = &datum;
00389     LALCDestroyArray ( &status, &array );
00390     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00391     ClearStatus( &status );
00392   }
00393 
00394 #else
00395   array = &astore;
00396   array->data = &datum;
00397   badLength1.data = NULL;
00398   badLength2.length = 0;
00399   badLength3.data = dbad;
00400 #endif
00401 
00402   LALCheckMemoryLeaks();
00403   printf( "PASS: tests of LALCCreateArray, LALCResizeArray, and LALCDestroyArray \n" );
00404           
00405   return;
00406 }
00407 
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 
00419 
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427 
00428 static void DArrayFactoriesTest ( void )
00429 {
00430   static UINT4   dims[3]    = { 1, 2, 4 };
00431   static UINT4   dbad[3]    = { 1, 0, 4 };
00432   UINT4Vector    dimLength  = { 3, dims };
00433   UINT4Vector    badLength1 = { 3, NULL };
00434   UINT4Vector    badLength2 = { 0, dims };
00435   UINT4Vector    badLength3 = { 3, dbad };
00436   static LALStatus  status;
00437   static REAL8Array  *array;
00438   static REAL8Array   astore;
00439   static REAL8    datum;
00440 
00441 
00442   /*
00443    *
00444    * Test ordinary behavior.
00445    *
00446    */
00447 
00448 
00449   LALDCreateArray ( &status, &array, &dimLength );
00450   TestStatus( &status, CODES( 0 ), 1 );
00451 
00452   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL8 ) );
00453 
00454   /* resize up */
00455   /*
00456    * dimLength.data[0] *= 2;
00457    * dimLength.data[1] *= 3;
00458    * dimLength.data[2] *= 4;
00459   */
00460   dims[0] *= 2;
00461   dims[1] *= 3;
00462   dims[2] *= 4;
00463   LALDResizeArray ( &status, &array, &dimLength );
00464   TestStatus( &status, CODES( 0 ), 1 );
00465   
00466   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL8 ) );
00467   
00468   /* resize down */
00469   dims[0] /= 2;
00470   dims[1] /= 3;
00471   dims[2] /= 2;
00472   LALDResizeArray ( &status, &array, &dimLength );
00473   TestStatus( &status, CODES( 0 ), 1 );
00474   
00475   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL8 ) );
00476   
00477   /* resize down again */
00478   dims[2] /= 2;
00479   LALDResizeArray ( &status, &array, &dimLength );
00480   TestStatus( &status, CODES( 0 ), 1 );
00481   
00482   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL8 ) );
00483   
00484   LALDDestroyArray ( &status, &array );
00485   TestStatus( &status, CODES( 0 ), 1 );
00486 
00487   LALCheckMemoryLeaks();
00488 
00489 
00490   /*
00491    *
00492    * Test error codes.
00493    *
00494    */
00495 
00496 
00497 #ifndef LAL_NDEBUG
00498 
00499   if ( ! lalNoDebug )
00500   {
00501     LALDCreateArray ( &status, &array, &badLength1 );
00502     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00503 
00504     LALDResizeArray ( &status, &array, &badLength1 );
00505     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00506 
00507     LALDCreateArray ( &status, &array, &badLength2 );
00508     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00509 
00510     LALDResizeArray ( &status, &array, &badLength2 );
00511     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00512 
00513     LALDCreateArray ( &status, &array, &badLength3 );
00514     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00515 
00516     LALDResizeArray ( &status, &array, &badLength3 );
00517     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00518     LALCheckMemoryLeaks();
00519 
00520     LALDDestroyArray ( &status, NULL );
00521     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00522 
00523     LALDCreateArray ( &status, NULL, &dimLength );
00524     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00525 
00526     LALDResizeArray ( &status, NULL, &badLength1 );
00527     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00528 
00529     LALDDestroyArray ( &status, &array );
00530     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00531 
00532     array = &astore;
00533     LALDCreateArray ( &status, &array, &dimLength );
00534     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00535 
00536     LALDResizeArray ( &status, &array, &badLength1 );
00537     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);
00538 
00539     LALDResizeArray ( &status, &array, &badLength2 );
00540     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00541 
00542     LALDResizeArray ( &status, &array, &badLength3 );
00543     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00544 
00545     LALDDestroyArray ( &status, &array );
00546     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00547 
00548     array->data = &datum;
00549     LALDDestroyArray ( &status, &array );
00550     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00551     ClearStatus( &status );
00552   }
00553 
00554 #else
00555   array = &astore;
00556   array->data = &datum;
00557   badLength1.data = NULL;
00558   badLength2.length = 0;
00559   badLength3.data = dbad;
00560 #endif
00561 
00562   LALCheckMemoryLeaks();
00563   printf( "PASS: tests of LALDCreateArray, LALDResizeArray, and LALDDestroyArray \n" );
00564           
00565   return;
00566 }
00567 
00568 
00569 
00570 
00571 
00572 
00573 
00574 
00575 
00576 
00577 
00578 
00579 
00580 
00581 
00582 
00583 
00584 
00585 
00586 
00587 
00588 static void SArrayFactoriesTest ( void )
00589 {
00590   static UINT4   dims[3]    = { 1, 2, 4 };
00591   static UINT4   dbad[3]    = { 1, 0, 4 };
00592   UINT4Vector    dimLength  = { 3, dims };
00593   UINT4Vector    badLength1 = { 3, NULL };
00594   UINT4Vector    badLength2 = { 0, dims };
00595   UINT4Vector    badLength3 = { 3, dbad };
00596   static LALStatus  status;
00597   static REAL4Array  *array;
00598   static REAL4Array   astore;
00599   static REAL4    datum;
00600 
00601 
00602   /*
00603    *
00604    * Test ordinary behavior.
00605    *
00606    */
00607 
00608 
00609   LALSCreateArray ( &status, &array, &dimLength );
00610   TestStatus( &status, CODES( 0 ), 1 );
00611 
00612   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL4 ) );
00613 
00614   /* resize up */
00615   /*
00616    * dimLength.data[0] *= 2;
00617    * dimLength.data[1] *= 3;
00618    * dimLength.data[2] *= 4;
00619   */
00620   dims[0] *= 2;
00621   dims[1] *= 3;
00622   dims[2] *= 4;
00623   LALSResizeArray ( &status, &array, &dimLength );
00624   TestStatus( &status, CODES( 0 ), 1 );
00625   
00626   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL4 ) );
00627   
00628   /* resize down */
00629   dims[0] /= 2;
00630   dims[1] /= 3;
00631   dims[2] /= 2;
00632   LALSResizeArray ( &status, &array, &dimLength );
00633   TestStatus( &status, CODES( 0 ), 1 );
00634   
00635   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL4 ) );
00636   
00637   /* resize down again */
00638   dims[2] /= 2;
00639   LALSResizeArray ( &status, &array, &dimLength );
00640   TestStatus( &status, CODES( 0 ), 1 );
00641   
00642   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( REAL4 ) );
00643   
00644   LALSDestroyArray ( &status, &array );
00645   TestStatus( &status, CODES( 0 ), 1 );
00646 
00647   LALCheckMemoryLeaks();
00648 
00649 
00650   /*
00651    *
00652    * Test error codes.
00653    *
00654    */
00655 
00656 
00657 #ifndef LAL_NDEBUG
00658 
00659   if ( ! lalNoDebug )
00660   {
00661     LALSCreateArray ( &status, &array, &badLength1 );
00662     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00663 
00664     LALSResizeArray ( &status, &array, &badLength1 );
00665     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00666 
00667     LALSCreateArray ( &status, &array, &badLength2 );
00668     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00669 
00670     LALSResizeArray ( &status, &array, &badLength2 );
00671     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00672 
00673     LALSCreateArray ( &status, &array, &badLength3 );
00674     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00675 
00676     LALSResizeArray ( &status, &array, &badLength3 );
00677     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00678     LALCheckMemoryLeaks();
00679 
00680     LALSDestroyArray ( &status, NULL );
00681     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00682 
00683     LALSCreateArray ( &status, NULL, &dimLength );
00684     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00685 
00686     LALSResizeArray ( &status, NULL, &badLength1 );
00687     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00688 
00689     LALSDestroyArray ( &status, &array );
00690     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00691 
00692     array = &astore;
00693     LALSCreateArray ( &status, &array, &dimLength );
00694     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00695 
00696     LALSResizeArray ( &status, &array, &badLength1 );
00697     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);
00698 
00699     LALSResizeArray ( &status, &array, &badLength2 );
00700     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00701 
00702     LALSResizeArray ( &status, &array, &badLength3 );
00703     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00704 
00705     LALSDestroyArray ( &status, &array );
00706     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00707 
00708     array->data = &datum;
00709     LALSDestroyArray ( &status, &array );
00710     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00711     ClearStatus( &status );
00712   }
00713 
00714 #else
00715   array = &astore;
00716   array->data = &datum;
00717   badLength1.data = NULL;
00718   badLength2.length = 0;
00719   badLength3.data = dbad;
00720 #endif
00721 
00722   LALCheckMemoryLeaks();
00723   printf( "PASS: tests of LALSCreateArray, LALSResizeArray, and LALSDestroyArray \n" );
00724           
00725   return;
00726 }
00727 
00728 
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736 
00737 
00738 
00739 
00740 
00741 
00742 
00743 
00744 
00745 
00746 
00747 
00748 static void I2ArrayFactoriesTest ( void )
00749 {
00750   static UINT4   dims[3]    = { 1, 2, 4 };
00751   static UINT4   dbad[3]    = { 1, 0, 4 };
00752   UINT4Vector    dimLength  = { 3, dims };
00753   UINT4Vector    badLength1 = { 3, NULL };
00754   UINT4Vector    badLength2 = { 0, dims };
00755   UINT4Vector    badLength3 = { 3, dbad };
00756   static LALStatus  status;
00757   static INT2Array  *array;
00758   static INT2Array   astore;
00759   static INT2    datum;
00760 
00761 
00762   /*
00763    *
00764    * Test ordinary behavior.
00765    *
00766    */
00767 
00768 
00769   LALI2CreateArray ( &status, &array, &dimLength );
00770   TestStatus( &status, CODES( 0 ), 1 );
00771 
00772   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( INT2 ) );
00773 
00774   /* resize up */
00775   /*
00776    * dimLength.data[0] *= 2;
00777    * dimLength.data[1] *= 3;
00778    * dimLength.data[2] *= 4;
00779   */
00780   dims[0] *= 2;
00781   dims[1] *= 3;
00782   dims[2] *= 4;
00783   LALI2ResizeArray ( &status, &array, &dimLength );
00784   TestStatus( &status, CODES( 0 ), 1 );
00785   
00786   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( INT2 ) );
00787   
00788   /* resize down */
00789   dims[0] /= 2;
00790   dims[1] /= 3;
00791   dims[2] /= 2;
00792   LALI2ResizeArray ( &status, &array, &dimLength );
00793   TestStatus( &status, CODES( 0 ), 1 );
00794   
00795   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( INT2 ) );
00796   
00797   /* resize down again */
00798   dims[2] /= 2;
00799   LALI2ResizeArray ( &status, &array, &dimLength );
00800   TestStatus( &status, CODES( 0 ), 1 );
00801   
00802   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( INT2 ) );
00803   
00804   LALI2DestroyArray ( &status, &array );
00805   TestStatus( &status, CODES( 0 ), 1 );
00806 
00807   LALCheckMemoryLeaks();
00808 
00809 
00810   /*
00811    *
00812    * Test error codes.
00813    *
00814    */
00815 
00816 
00817 #ifndef LAL_NDEBUG
00818 
00819   if ( ! lalNoDebug )
00820   {
00821     LALI2CreateArray ( &status, &array, &badLength1 );
00822     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00823 
00824     LALI2ResizeArray ( &status, &array, &badLength1 );
00825     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00826 
00827     LALI2CreateArray ( &status, &array, &badLength2 );
00828     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00829 
00830     LALI2ResizeArray ( &status, &array, &badLength2 );
00831     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00832 
00833     LALI2CreateArray ( &status, &array, &badLength3 );
00834     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00835 
00836     LALI2ResizeArray ( &status, &array, &badLength3 );
00837     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
00838     LALCheckMemoryLeaks();
00839 
00840     LALI2DestroyArray ( &status, NULL );
00841     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00842 
00843     LALI2CreateArray ( &status, NULL, &dimLength );
00844     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00845 
00846     LALI2ResizeArray ( &status, NULL, &badLength1 );
00847     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );
00848 
00849     LALI2DestroyArray ( &status, &array );
00850     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00851 
00852     array = &astore;
00853     LALI2CreateArray ( &status, &array, &dimLength );
00854     TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );
00855 
00856     LALI2ResizeArray ( &status, &array, &badLength1 );
00857     TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);
00858 
00859     LALI2ResizeArray ( &status, &array, &badLength2 );
00860     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00861 
00862     LALI2ResizeArray ( &status, &array, &badLength3 );
00863     TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);
00864 
00865     LALI2DestroyArray ( &status, &array );
00866     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00867 
00868     array->data = &datum;
00869     LALI2DestroyArray ( &status, &array );
00870     TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
00871     ClearStatus( &status );
00872   }
00873 
00874 #else
00875   array = &astore;
00876   array->data = &datum;
00877   badLength1.data = NULL;
00878   badLength2.length = 0;
00879   badLength3.data = dbad;
00880 #endif
00881 
00882   LALCheckMemoryLeaks();
00883   printf( "PASS: tests of LALI2CreateArray, LALI2ResizeArray, and LALI2DestroyArray \n" );
00884           
00885   return;
00886 }
00887 
00888 
00889 
00890 
00891 
00892 
00893 
00894 
00895 
00896 
00897 
00898 
00899 
00900 
00901 
00902 
00903 
00904 
00905 
00906 
00907 
00908 static void I4ArrayFactoriesTest ( void )
00909 {
00910   static UINT4   dims[3]    = { 1, 2, 4 };
00911   static UINT4   dbad[3]    = { 1, 0, 4 };
00912   UINT4Vector    dimLength  = { 3, dims };
00913   UINT4Vector    badLength1 = { 3, NULL };
00914   UINT4Vector    badLength2 = { 0, dims };
00915   UINT4Vector    badLength3 = { 3, dbad };
00916   static LALStatus  status;
00917   static INT4Array  *array;
00918   static INT4Array   astore;
00919   static INT4    datum;
00920 
00921 
00922   /*
00923    *
00924    * Test ordinary behavior.
00925    *
00926    */
00927 
00928 
00929   LALI4CreateArray ( &status, &array, &dimLength );
00930   TestStatus( &status, CODES( 0 ), 1 );
00931 
00932   memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( INT4 ) );
00933 
00934   /* resize up */
00935   /*
00936    * dimLength.data[0] *= 2;
00937    * dimLength.data[1] *= 3;
00938    * dimLength.data[2] *= 4;
00939   */
00940   dims[0] *= 2;
00941   dims[1] *= 3;
00942   dims[2] *= 4;
00943   LALI4ResizeArray ( &status, &array, &dimLength );
00944   TestStatus( &status,