GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

GATString_tests.c

Go to the documentation of this file.
00001 /** @file GATString_test.c
00002  * 
00003  *  Source file for the GATString_test class.
00004  *
00005  *  @date $Date: 2004/04/02 12:31:58 $
00006  *
00007  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/internal/GATString_tests.c,v 1.15 2004/04/02 12:31:58 hartmutkaiser Exp $
00008  *
00009  *  Copyright (C) Kelly Davis
00010  *  This file is part of the GAT Engine.
00011  *  Contributed by Kelly Davis <kdavis [at] aei [dot] mpg [dot] de>.
00012  *
00013  *  Use, modification and distribution is subject to the Gridlab Software
00014  *  License. (See accompanying file GLlicense.txt or copy at
00015  *  http://www.gridlab.org/GLlicense.txt)
00016  */
00017 
00018 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/internal/GATString_tests.c,v 1.15 2004/04/02 12:31:58 hartmutkaiser Exp $";
00019 
00020 /* System Header Files */
00021 #include <stdio.h>
00022 #include <stddef.h>
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <errno.h>
00026 
00027 /* GAT Header Files */
00028 #include "GAT.h"
00029 #include <iconv.h>
00030 
00031 #include "GATTestUtils.h"
00032 
00033 /* Macros */
00034 
00035 /* Structures, unions and enums */
00036 
00037 /* Static function prototypes */
00038 static GATBool GATString_Create_Test_Harness   ( void );
00039 static GATBool GATString_Create_Test           ( void );
00040 static GATBool GATString_GetType_Test          ( void );
00041 static GATBool GATString_Clone_Test            ( void );
00042 static GATBool GATString_Destroy_Test          ( void );
00043 static GATBool GATString_GetLengthInBytes_Test ( void );
00044 static GATBool GATString_GetBuffer_Test        ( void );
00045 static GATBool GATString_GetEncoding_Test      ( void );
00046 static GATBool GATString_Translate_Test        ( void );
00047 static GATBool GATString_CompareTo_Test        ( void );
00048 static GATBool GATString_EndsWith_Test         ( void );
00049 static GATBool GATString_StartsWith_Test       ( void );
00050 static GATBool GATString_Concatenate_Test      ( void );
00051 static GATBool GATString_LastIndexOf_Test      ( void );
00052 static GATBool GATString_FirstIndexOf_Test     ( void );
00053 static GATBool GATString_GetSubString_Test     ( void );
00054 static GATBool GATString_GetInterface_Test     ( void );
00055 static GATBool GATString_Destroy_Test_Harness  ( void );
00056 
00057 /* Static Utility Functions */
00058 static void GATString_Create_XXX_Files( void );
00059 static void GATString_Write_XXX( FILE *newFile, const char *encoding );
00060 static void GATString_Create_XXX_To_UCS_4_INTERNAL_Files( void );
00061 static void GATString_Create_UCS_4_INTERNAL_To_XXX_Files( void );
00062 static void GATString_Write_XXX_To_UCS_4_INTERNAL( FILE *newFile, const char *encoding );
00063 static void GATString_Write_UCS_4_INTERNAL_To_XXX( FILE *newFile, const char *encoding );
00064 static int GATString_Try_Conversion(iconv_t cd, unsigned char buf[], unsigned int buflen, unsigned int* out);
00065 static const char* GATString_UCS4_Decode(const unsigned int* out, unsigned int outlen);
00066 // static const char* GATString_Hexbuf(unsigned char buf[], unsigned int buflen);
00067 
00068 /* File scope variables */
00069 static int bmp_only; /* If nonzero, ignore conversions outside Unicode plane 0. */
00070 
00071 /* External functions */
00072 int main (void)
00073 {
00074   GAT_TEST_INIT (-1);
00075 
00076   GAT_TEST_SUITE("GAT String");
00077 
00078   GAT_TEST( GATString_Create_Test_Harness  () );
00079   GAT_TEST( GATString_Create_Test          () );
00080   GAT_TEST( GATString_GetType_Test         () );
00081   GAT_TEST( GATString_Clone_Test           () );
00082   GAT_TEST( GATString_Destroy_Test         () );
00083   GAT_TEST( GATString_GetLengthInBytes_Test() );
00084   GAT_TEST( GATString_GetBuffer_Test       () );
00085   GAT_TEST( GATString_GetEncoding_Test     () );
00086   /* GAT_TEST( GATString_Translate_Test       () ); */
00087   /* GAT_TEST( GATString_CompareTo_Test       () ); */
00088   /* GAT_TEST( GATString_EndsWith_Test        () ); */
00089   /* GAT_TEST( GATString_StartsWith_Test      () ); */
00090   GAT_TEST( GATString_Concatenate_Test     () );
00091   GAT_TEST( GATString_LastIndexOf_Test     () );
00092   GAT_TEST( GATString_FirstIndexOf_Test    () );
00093   GAT_TEST( GATString_GetSubString_Test    () );
00094   GAT_TEST( GATString_GetInterface_Test    () );
00095   GAT_TEST( GATString_Destroy_Test_Harness () );
00096 
00097   GAT_TEST_FINISH ();
00098 
00099   return (0);
00100 }
00101 
00102 static GATBool GATString_Create_Test_Harness()
00103 {
00104   // GAT_TEST_START("GATString Create Test Harness");
00105 
00106   /* Create files XXX */
00107   GATString_Create_XXX_Files();
00108   
00109   /* Create files XXX-to-UCS-4-INTERNAL */
00110   GATString_Create_XXX_To_UCS_4_INTERNAL_Files();
00111   
00112   /* Create files UCS-4-INTERNAL-to-XXX */
00113   GATString_Create_UCS_4_INTERNAL_To_XXX_Files();
00114 
00115   // GAT_TEST_STOP ();
00116 
00117   return (GATTrue);
00118 }
00119 
00120 static void GATString_Create_XXX_Files( void )
00121 {
00122   // GAT_TEST_START("GATString Create XXX Files");
00123 
00124   FILE       *newFile;
00125   char        encoding[41];
00126   FILE       *encodingFile;
00127   char        encodingFileName[256];
00128   const char *newFileName;
00129   char        newTestName[256];
00130   
00131   sprintf(encodingFileName, "%s", ENCFILE);
00132 
00133   /* Open encoding file */
00134   encodingFile = fopen (encodingFileName, "r" );
00135   fprintf (stderr, "---- %s\n", encodingFileName);
00136   GAT_TEST( NULL != encodingFile );
00137 
00138   /* Get next encoding */
00139   while( NULL != fgets(encoding, 41, encodingFile) )
00140   {
00141     /* remove the trailing '\n' */
00142     char *eol = strchr(encoding, '\n');
00143     
00144     if (NULL != eol)
00145     {
00146       *eol = '\0';
00147     }
00148 
00149     /* Create new file name */
00150     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
00151     GAT_TEST (newFileName);
00152     
00153     sprintf(newTestName, "Create File: %s", encoding);
00154     
00155     /* Open new file */
00156     newFile = fopen( newFileName, "w" );
00157     GAT_TEST( NULL != newFile );
00158     
00159     GAT_TEST_START (newTestName);
00160 
00161     /* Write to new file */
00162     GATString_Write_XXX( newFile, encoding );
00163     
00164     /* Close new file */
00165     fclose( newFile );
00166     GAT_TEST_STOP ();
00167   }
00168   
00169   /* Close encoding file */
00170   fclose( encodingFile );
00171 
00172   // GAT_TEST_STOP ();
00173 }
00174 
00175 static void GATString_Write_XXX( FILE *newFile, const char *charset )
00176 {
00177   iconv_t cd;
00178   int search_depth;
00179   char newTestName [256];
00180 
00181   sprintf (newTestName, "Write File: %s", charset);
00182   GAT_TEST_START (newTestName);
00183 
00184   cd = iconv_open("UCS-4-INTERNAL",charset);
00185   if (cd == (iconv_t)(-1)) 
00186   {
00187     // perror("iconv_open failed");
00188     // exit(1);
00189     GAT_TEST (0);
00190     return;
00191   }
00192 
00193   /* When testing some charstes, stop at 0x10000, 
00194    * otherwise the output file gets too big. 
00195    */
00196   search_depth = 4;
00197   
00198   if ( ! strcmp(charset,"UTF-8"     ) ||
00199        ! strcmp(charset,"GB18030"   ) ||
00200        ! strcmp(charset,"UCS-4BE"   ) ||
00201        ! strcmp(charset,"UCS-4LE"   ) ||
00202        ! strcmp(charset,"UTF-16"    ) ||
00203        ! strcmp(charset,"UTF-16BE"  ) ||
00204        ! strcmp(charset,"UTF-16LE"  ) ||
00205        ! strcmp(charset,"UTF-32"    ) ||
00206        ! strcmp(charset,"UTF-32BE"  ) ||
00207        ! strcmp(charset,"UTF-32LE"  ) ||
00208        ! strcmp(charset,"UCS-4"     ) )
00209   {
00210     search_depth = 3;
00211   }
00212 
00213   {
00214     unsigned int  out[3];
00215     unsigned char buf[4];
00216     unsigned int  i0, i1, i2, i3;
00217     int result;
00218     
00219     for (i0 = 0; i0 < 0x100; i0++) {
00220       // fprintf (stderr, "-- -- --> i0 %d / %d\n", i0, 0x100);
00221       buf[0] = i0;
00222       result = GATString_Try_Conversion(cd,buf,1,out);
00223       if (result < 0) {
00224       } else if (result > 0) {
00225         const char* unicode = GATString_UCS4_Decode(out,result);
00226         if (unicode)
00227         {
00228           fprintf(newFile,"%d\n",1);
00229           fprintf(newFile,"0x%02X\t%s\n",i0,charset);
00230         }
00231       } else {
00232         for (i1 = 0; i1 < 0x100; i1++) {
00233           // fprintf (stderr, "-- -- --> i1 %d / %d\n", i1, 0x100);
00234           buf[1] = i1;
00235           result = GATString_Try_Conversion(cd,buf,2,out);
00236           if (result < 0) {
00237           } else if (result > 0) {
00238             const char* unicode = GATString_UCS4_Decode(out,result);
00239             if (unicode)
00240             {
00241               fprintf(newFile,"%d\n",2);
00242               fprintf(newFile,"0x%02X%02X\t%s\n",i0,i1,charset);
00243             }
00244           } else {
00245             for (i2 = 0; i2 < 0x100; i2++) {
00246               // fprintf (stderr, "   -- --> i2 %d\n", i2);
00247               buf[2] = i2;
00248               result = GATString_Try_Conversion(cd,buf,3,out);
00249               if (result < 0) {
00250               } else if (result > 0) {
00251                 const char* unicode = GATString_UCS4_Decode(out,result);
00252                 if (unicode)
00253                 {
00254                   fprintf(newFile,"%d\n",3);
00255                   fprintf(newFile,"0x%02X%02X%02X\t%s\n",i0,i1,i2,charset);
00256                 }
00257               } else if (search_depth > 3) {
00258                 for (i3 = 0; i3 < 0x100; i3++) {
00259                   // fprintf (stderr, "      --> i3 %d\n", i3);
00260                   buf[3] = i3;
00261                   result = GATString_Try_Conversion(cd,buf,4,out);
00262                   if (result < 0) {
00263                   } else if (result > 0) {
00264                     const char* unicode = GATString_UCS4_Decode(out,result);
00265                     if (unicode)
00266                     {
00267                       fprintf(newFile,"%d\n",4);
00268                       fprintf(newFile,"0x%02X%02X%02X%02X\t%s\n",i0,i1,i2,i3,charset);
00269                     }
00270                   } else {
00271                     // fprintf(stderr,"%s: incomplete byte sequence\n",GATString_Hexbuf(buf,4));
00272                     // exit(1);
00273                     GAT_TEST (0);
00274                     GAT_TEST_EXIT ();
00275                     return;
00276                   }
00277                 }
00278               }
00279             }
00280           }
00281         }
00282       }
00283     }
00284   }
00285 
00286   if (iconv_close(cd) < 0) {
00287     // perror("iconv_close failed");
00288     // exit(1);
00289     GAT_TEST (0);
00290   }
00291 
00292   if (ferror(stdin) || ferror(stdout)) {
00293     // fprintf(stderr,"I/O error\n");
00294     // exit(1);
00295     GAT_TEST (0);
00296   }
00297 
00298   GAT_TEST_STOP ();
00299   return;
00300 }
00301 
00302 static void GATString_Create_XXX_To_UCS_4_INTERNAL_Files( void )
00303 {
00304   FILE       *newFile;
00305   char        encoding[41];
00306   FILE       *encodingFile;
00307   char        encodingFileName[256];
00308   const char *newFileName;
00309   char        newTestName[256];
00310   
00311   const char* tmpdir = GATTest_GetTempDirName ();
00312   if ( ! tmpdir )
00313   {
00314     GAT_TEST (0);
00315     fprintf (stderr, "No tmpdir\n");
00316     return;
00317   }
00318   
00319   sprintf(encodingFileName, "%s", ENCFILE);
00320 
00321   /* Open encoding file */
00322   encodingFile = fopen( encodingFileName, "r" );
00323   GAT_TEST( NULL != encodingFile );
00324   
00325   /* Get next encoding */
00326   while( NULL != fgets(encoding, 41, encodingFile) )
00327   {
00328     /* remove the trailing '\n' */
00329     char *eol = strchr(encoding, '\n');
00330     
00331     if (NULL != eol)
00332     {
00333       *eol = '\0';
00334     }
00335     
00336     /* Create new file name */
00337     newFileName = GATTest_GetTempFileNameF ("gat_%s_To_UCS_4_INTERNAL", encoding);
00338     GAT_TEST (newFileName);
00339     
00340     sprintf(newTestName, "Create %s to UCS_4_INTERNAL File", encoding);
00341 
00342     GAT_TEST_START (newTestName);
00343     
00344     /* Open new file */
00345     newFile = fopen( newFileName, "w" );
00346     GAT_TEST( NULL != newFile );
00347     
00348     /* Write to new file */
00349     GATString_Write_XXX_To_UCS_4_INTERNAL( newFile, encoding );
00350     
00351     /* Close new file */
00352     fclose( newFile );
00353     GAT_TEST_STOP ();
00354   }
00355   
00356   /* Close encoding file */
00357   fclose( encodingFile );
00358 }
00359 
00360 static void GATString_Write_XXX_To_UCS_4_INTERNAL( FILE *newFile, const char *charset )
00361 {
00362   iconv_t cd;
00363   int search_depth;
00364   char newTestName [256];
00365 
00366   sprintf (newTestName, "Write %s to UCS_4_INTERNAL File", charset);
00367   GAT_TEST_START(newTestName);
00368 
00369   cd = iconv_open("UCS-4-INTERNAL",charset);
00370   if (cd == (iconv_t)(-1)) 
00371   {
00372     GAT_TEST (0);
00373     GAT_TEST_EXIT ();
00374     return;
00375     // perror("iconv_open failed");
00376     // exit(1);
00377   }
00378 
00379   /* When testing some charstes, stop at 0x10000, 
00380    * otherwise the output file gets too big. 
00381    */
00382   search_depth = 4;
00383   
00384   if ( ! strcmp(charset,"UTF-8"     ) ||
00385        ! strcmp(charset,"GB18030"   ) ||
00386        ! strcmp(charset,"UCS-4BE"   ) ||
00387        ! strcmp(charset,"UCS-4LE"   ) ||
00388        ! strcmp(charset,"UTF-16"    ) ||
00389        ! strcmp(charset,"UTF-16BE"  ) ||
00390        ! strcmp(charset,"UTF-16LE"  ) ||
00391        ! strcmp(charset,"UTF-32"    ) ||
00392        ! strcmp(charset,"UTF-32BE"  ) ||
00393        ! strcmp(charset,"UTF-32LE"  ) ||
00394        ! strcmp(charset,"UCS-4"     ) )
00395   {
00396     search_depth = 3;
00397   }
00398 
00399 
00400   {
00401     unsigned int out[3];
00402     unsigned char buf[4];
00403     unsigned int i0, i1, i2, i3;
00404     int result;
00405     for (i0 = 0; i0 < 0x100; i0++) {
00406       buf[0] = i0;
00407       result = GATString_Try_Conversion(cd,buf,1,out);
00408       if (result < 0) {
00409       } else if (result > 0) {
00410         const char* unicode = GATString_UCS4_Decode(out,result);
00411         if (unicode)
00412         {
00413           fprintf(newFile,"%d\n",1);
00414           fprintf(newFile,"0x%02X\t%s\n",i0,unicode);
00415         }
00416       } else {
00417         for (i1 = 0; i1 < 0x100; i1++) {
00418           buf[1] = i1;
00419           result = GATString_Try_Conversion(cd,buf,2,out);
00420           if (result < 0) {
00421           } else if (result > 0) {
00422             const char* unicode = GATString_UCS4_Decode(out,result);
00423             if (unicode)
00424             {
00425               fprintf(newFile,"%d\n",2);
00426               fprintf(newFile,"0x%02X%02X\t%s\n",i0,i1,unicode);
00427             }
00428           } else {
00429             for (i2 = 0; i2 < 0x100; i2++) {
00430               buf[2] = i2;
00431               result = GATString_Try_Conversion(cd,buf,3,out);
00432               if (result < 0) {
00433               } else if (result > 0) {
00434                 const char* unicode = GATString_UCS4_Decode(out,result);
00435                 if (unicode)
00436                 {
00437                   fprintf(newFile,"%d\n",3);
00438                   fprintf(newFile,"0x%02X%02X%02X\t%s\n",i0,i1,i2,unicode);
00439                 }
00440               } else if (search_depth > 3) {
00441                 for (i3 = 0; i3 < 0x100; i3++) {
00442                   buf[3] = i3;
00443                   result = GATString_Try_Conversion(cd,buf,4,out);
00444                   if (result < 0) {
00445                   } else if (result > 0) {
00446                     const char* unicode = GATString_UCS4_Decode(out,result);
00447                     if (unicode)
00448                     {
00449                       fprintf(newFile,"%d\n",4);
00450                       fprintf(newFile,"0x%02X%02X%02X%02X\t%s\n",i0,i1,i2,i3,unicode);
00451                     }
00452                   } else {
00453                     GAT_TEST (0);
00454                     GAT_TEST_EXIT ();
00455                     return;
00456                     // fprintf(stderr,"%s: incomplete byte sequence\n",GATString_Hexbuf(buf,4));
00457                     // exit(1);
00458                   }
00459                 }
00460               }
00461             }
00462           }
00463         }
00464       }
00465     }
00466   }
00467 
00468   if (iconv_close(cd) < 0) {
00469     GAT_TEST (0);
00470     // perror("iconv_close failed");
00471     // exit(1);
00472   }
00473 
00474   if (ferror(stdin) || ferror(stdout)) {
00475     GAT_TEST (0);
00476     // fprintf(stderr,"I/O error\n");
00477     // exit(1);
00478   }
00479 
00480 //exit(0);
00481 
00482   GAT_TEST_STOP ();
00483 }
00484 
00485 static int GATString_Try_Conversion(iconv_t cd, unsigned char buf[], unsigned int buflen, unsigned int* out)
00486 {
00487 
00488   const char* inbuf = (const char*) buf;
00489   size_t inbytesleft = buflen;
00490   char* outbuf = (char*) out;
00491   size_t outbytesleft = 3*sizeof(unsigned int);
00492   size_t result;
00493   
00494   GAT_TEST_START("GATString Try Conversion");
00495   
00496   iconv(cd,NULL,NULL,NULL,NULL);
00497   result = iconv(cd,(const char**)&inbuf,&inbytesleft,&outbuf,&outbytesleft);
00498   if (result != (size_t)(-1))
00499     result = iconv(cd,NULL,NULL,&outbuf,&outbytesleft);
00500   if (result == (size_t)(-1)) {
00501     if (errno == EILSEQ) {
00502       result = -1;
00503     } else if (errno == EINVAL) {
00504       result = 0;
00505     } else {
00506       int saved_errno = errno;
00507       // fprintf(stderr,"%s: iconv error: ",GATString_Hexbuf(buf,buflen));
00508       errno = saved_errno;
00509       // perror("");
00510       // exit(1);
00511       result = -1;
00512     }
00513   } else if (result > 0) /* ignore conversions with transliteration */ {
00514     result = -1;
00515   } else {
00516     if (inbytesleft != 0) {
00517       // fprintf(stderr,"%s: inbytes = %ld, outbytes = %ld\n",
00518       //         GATString_Hexbuf(buf,buflen),
00519       //         (long)(buflen-inbytesleft),
00520       //         (long)(3*sizeof(unsigned int)-outbytesleft));
00521       // exit(1);
00522       result = -1;
00523     }
00524     else
00525     {
00526       result = (3*sizeof(unsigned int)-outbytesleft)/sizeof(unsigned int);
00527     }
00528   }
00529 
00530   GAT_TEST_STOP ();
00531   return (int)(result);
00532 }
00533 
00534 static const char* GATString_UCS4_Decode(const unsigned int* out, unsigned int outlen)
00535 {
00536   static char hexbuf[21];
00537   char *p = hexbuf;
00538   
00539   if( 1 == outlen )
00540    sprintf (p, "0x0000%04X", out[0]);
00541   if( 2 == outlen )
00542    sprintf (p, "0x%04X%04X", out[0], out[1]);
00543    
00544   return hexbuf;
00545 
00546   // static char hexbuf[21];
00547   // char* p = hexbuf;
00548   // while (outlen > 0) {
00549   //   if (p > hexbuf)
00550   //     *p++ = ' ';
00551   //   sprintf (p, "0x%04X", out[0]);
00552   //   out += 1; outlen -= 1;
00553   //   if (bmp_only && strlen(p) > 6)
00554   //   {
00555   //     return NULL;
00556   //   }
00557   //   p += strlen(p);
00558   // }
00559   // 
00560   // return hexbuf;
00561 }
00562 
00563 /*
00564 static const char* GATString_Hexbuf(unsigned char buf[], unsigned int buflen)
00565 {
00566 
00567   static char msg[50];
00568   switch (buflen) {
00569     case 1: sprintf(msg,"0x%02X",buf[0]); break;
00570     case 2: sprintf(msg,"0x%02X%02X",buf[0],buf[1]); break;
00571     case 3: sprintf(msg,"0x%02X%02X%02X",buf[0],buf[1],buf[2]); break;
00572     case 4: sprintf(msg,"0x%02X%02X%02X%02X",buf[0],buf[1],buf[2],buf[3]); break;
00573     default: abort();
00574   }
00575 
00576   return msg;
00577 }
00578 */
00579 
00580 static void GATString_Create_UCS_4_INTERNAL_To_XXX_Files( void )
00581 {
00582   FILE       *newFile;
00583   char        encoding[41];
00584   FILE       *encodingFile;
00585   char        encodingFileName[256];
00586   const char *newFileName;
00587   char        newTestName[256];
00588   
00589   const char* tmpdir = GATTest_GetTempDirName ();
00590   if ( ! tmpdir )
00591   {
00592     GAT_TEST (0);
00593     fprintf (stderr, "No tmpdir\n");
00594     return;
00595   }
00596   
00597   sprintf(encodingFileName, "%s", ENCFILE);
00598 
00599   /* Open encoding file */
00600   encodingFile = fopen( encodingFileName, "r" );
00601   GAT_TEST( NULL != encodingFile );
00602   
00603   /* Get next encoding */
00604   while( NULL != fgets(encoding, 41, encodingFile) )
00605   {
00606     /* remove the trailing '\n' */
00607     char *eol = strchr(encoding, '\n');
00608     
00609     if (NULL != eol)
00610     {
00611       *eol = '\0';
00612     }
00613     
00614     /* Create new file name */
00615     newFileName = GATTest_GetTempFileNameF ("gat_UCS_4_INTERNAL_To_%s", encoding);
00616     GAT_TEST (newFileName);
00617     
00618     sprintf (newTestName, "Write UCS_4_INTERNAL to %s File", encoding);
00619     GAT_TEST_START (newTestName);
00620     
00621     /* Open new file */
00622     newFile = fopen( newFileName, "w" );
00623     GAT_TEST( NULL != newFile );
00624     
00625     /* Write to new file */
00626     GATString_Write_UCS_4_INTERNAL_To_XXX( newFile, encoding );
00627     
00628     /* Close new file */
00629     fclose( newFile );
00630 
00631     GAT_TEST_STOP ();
00632   }
00633   
00634   /* Close encoding file */
00635   fclose( encodingFile );
00636 
00637   // GAT_TEST_STOP ();
00638 }
00639 
00640 static void GATString_Write_UCS_4_INTERNAL_To_XXX( FILE *newFile, const char *charset )
00641 {
00642   // GAT_TEST_START("GATString_Write_UCS_4_INTERNAL_To_XXX");
00643 
00644   iconv_t cd;
00645   int local_bmp_only;
00646 
00647   cd = iconv_open(charset,"UCS-4-INTERNAL");
00648   if (cd == (iconv_t)(-1)) 
00649   {
00650     GAT_TEST (0);
00651     // GAT_TEST_EXIT ();
00652     return;
00653     // perror("iconv_open");
00654     // exit(1);
00655   }
00656 
00657   /* When testing UTF-8 or GB18030, stop at 0x10000, otherwise the output file gets too big. */
00658   local_bmp_only = (strcmp(charset,"UTF-8") == 0 || strcmp(charset,"GB18030") == 0);
00659 
00660   {
00661     unsigned int i;
00662     unsigned char buf[10];
00663     for (i = 0; i < (unsigned int)(local_bmp_only ? 0x10000 : 0x30000); i++) {
00664       unsigned int in = i;
00665       const char* inbuf = (const char*) &in;
00666       size_t inbytesleft = sizeof(unsigned int);
00667       char* outbuf = (char*)buf;
00668       size_t outbytesleft = sizeof(buf);
00669       size_t result;
00670       size_t result2 = 0;
00671       iconv(cd,NULL,NULL,NULL,NULL);
00672       result = iconv(cd,(const char**)&inbuf,&inbytesleft,&outbuf,&outbytesleft);
00673       if (result != (size_t)(-1))
00674         result2 = iconv(cd,NULL,NULL,&outbuf,&outbytesleft);
00675       if (result == (size_t)(-1) || result2 == (size_t)(-1)) {
00676         if (errno != EILSEQ) {
00677           int saved_errno = errno;
00678           // fprintf(stderr,"0x%02X: iconv error: ",i);
00679           errno = saved_errno;
00680           // perror("");
00681           // exit(1);
00682           GAT_TEST (0);
00683           // GAT_TEST_EXIT ();
00684           return;
00685         }
00686       } else if (result == 0) /* ignore conversions with transliteration */ {
00687         unsigned int j, jmax;
00688         if (inbytesleft != 0 || outbytesleft == sizeof(buf)) {
00689           // fprintf(stderr,"0x%02X: inbytes = %ld, outbytes = %ld\n",i,
00690           //         (long)(sizeof(unsigned int)-inbytesleft),
00691           //         (long)(sizeof(buf)-outbytesleft));
00692           // exit(1);
00693           GAT_TEST (0);
00694           // GAT_TEST_EXIT ();
00695           return;
00696         }
00697         jmax = sizeof(buf) - outbytesleft;
00698         fprintf(newFile,"%d\n",jmax);
00699         fprintf(newFile, "0x");
00700         for (j = 0; j < jmax; j++)
00701           fprintf(newFile,"%02X",buf[j]);
00702         fprintf(newFile, "\t0x%08X\n",i);
00703       }
00704     }
00705   }
00706 
00707   if (iconv_close(cd) < 0) {
00708     // perror("iconv_close failed");
00709     // exit(1);
00710     GAT_TEST (0);
00711   }
00712 
00713   if (ferror(stdin) || ferror(stdout)) {
00714     // fprintf(stderr,"I/O error\n");
00715     // exit(1);
00716     GAT_TEST (0);
00717   }
00718 
00719 // exit(0);
00720 
00721 // GAT_TEST_EXIT ();
00722 }
00723 
00724 static GATBool GATString_Destroy_Test_Harness( void )
00725 {
00726   char        encoding[41];
00727   const char *fileName;
00728   FILE       *encodingFile;
00729   char        encodingFileName[256];
00730   
00731   GAT_TEST_START("GATString Destroy Test Harness");
00732 
00733   sprintf (encodingFileName, "%s", ENCFILE);
00734 
00735   /* Open encoding file */
00736   encodingFile = fopen( encodingFileName, "r" );
00737   GAT_TEST( NULL != encodingFile );
00738   
00739   /* Get next encoding */
00740   while( NULL != fgets (encoding, 41, encodingFile) )
00741   {
00742     /* remove the trailing '\n' */
00743     char *eol = strchr (encoding, '\n');
00744     
00745     if (NULL != eol)
00746     {
00747       *eol = '\0';
00748     }
00749     
00750     /* Create new file name */
00751     // sprintf(fileName, "%s", encoding);
00752     fileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
00753     
00754     /* Delete file */
00755     remove( fileName );
00756       
00757     /* Create new file name */
00758     fileName = GATTest_GetTempFileNameF ("gat_%s_To_UCS_4_INTERNAL", encoding);
00759     
00760     /* Delete file */
00761     remove( fileName );
00762     
00763     /* Create new file name */
00764     fileName = GATTest_GetTempFileNameF ("gat_UCS_4_INTERNAL_To_%s", encoding);
00765         
00766     /* Delete file */
00767     remove( fileName );
00768   }
00769   
00770   /* Close encoding file */
00771   fclose( encodingFile );
00772 
00773   GAT_TEST_STOP ();
00774 
00775   return (GATTrue);
00776 }
00777 
00778 static GATBool GATString_Create_Test( void )
00779 {
00780   int           retval;
00781   FILE         *newFile;
00782   char          charset[41];
00783   char          encoding[41];
00784   int           lengthInBytes;
00785   FILE         *encodingFile;
00786   char          encodingFileName[256];
00787   GATString     gatString;
00788   const char   *newFileName;
00789   char          newTestName[256];
00790   unsigned char buffer[4];
00791   unsigned int  i0, i1, i2, i3;
00792   
00793   sprintf(encodingFileName, "%s", ENCFILE);
00794 
00795   /* Open encoding file */
00796   encodingFile = fopen( encodingFileName, "r" );
00797   GAT_TEST( NULL != encodingFile );
00798   
00799   /* Get next encoding */
00800   while( NULL != fgets(encoding, 41, encodingFile) )
00801   {
00802     /* remove the trailing '\n' */
00803     char *eol = strchr(encoding, '\n');
00804     
00805     if (NULL != eol)
00806     {
00807       *eol = '\0';
00808     }
00809     
00810     /* Create new file name */
00811     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
00812     sprintf(newTestName, "GATString Create Test: %s", encoding);
00813 
00814     GAT_TEST_START (newTestName);
00815     
00816     /* Open new file */
00817     newFile = fopen( newFileName, "r" );
00818     GAT_TEST( NULL != newFile );
00819     
00820     /* Read in length in bytes */
00821     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
00822     {
00823       if( 1 == lengthInBytes )
00824       {
00825         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &charset);
00826         GAT_TEST( EOF != retval );
00827         
00828         buffer[0] = i0;
00829         
00830         gatString = GATString_Create( (const char *) buffer, 1, charset );
00831         GAT_TEST( NULL != gatString);
00832         GATString_Destroy( &gatString ); /* Note: Create implicitly tests destroy assuming we done leak memory */
00833       }
00834       
00835       if( 2 == lengthInBytes )
00836       {
00837         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &charset);
00838         GAT_TEST( EOF != retval );
00839         
00840         buffer[0] = i0;
00841         buffer[1] = i1;
00842         
00843         gatString = GATString_Create( (const char *) buffer, 2, charset );
00844         GAT_TEST( NULL != gatString);  
00845         GATString_Destroy( &gatString ); /* Note: Create implicitly tests destroy assuming we done leak memory */    
00846       }
00847       
00848       if( 3 == lengthInBytes )
00849       {
00850         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &charset);
00851         GAT_TEST( EOF != retval );
00852         
00853         buffer[0] = i0;
00854         buffer[1] = i1;
00855         buffer[2] = i2;
00856         
00857         gatString = GATString_Create( (const char *) buffer, 3, charset );
00858         GAT_TEST( NULL != gatString);        
00859         GATString_Destroy( &gatString ); /* Note: Create implicitly tests destroy assuming we done leak memory */
00860       }
00861       
00862       if( 4 == lengthInBytes )
00863       {
00864         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &charset);
00865         GAT_TEST( EOF != retval );
00866         
00867         buffer[0] = i0;
00868         buffer[1] = i1;
00869         buffer[2] = i2;
00870         buffer[3] = i3;
00871         
00872         gatString = GATString_Create( (const char *) buffer, 4, charset );
00873         GAT_TEST( NULL != gatString);  
00874         GATString_Destroy( &gatString ); /* Note: Create implicitly tests destroy assuming we done leak memory */         
00875       }
00876     }
00877     
00878     GAT_TEST_STOP ();
00879     
00880     /* Close new file */
00881     fclose( newFile );
00882   }
00883   
00884   /* Close encoding file */
00885   fclose( encodingFile );
00886   
00887   return GATTrue;
00888 }
00889 
00890 static GATBool GATString_GetType_Test( void )
00891 {
00892   GATType gatType;
00893   GATString gatString;
00894   
00895   GAT_TEST_START("GATString GetType Test");
00896 
00897   gatString = GATString_Create( "test", 5, "ASCII" );
00898   GAT_TEST (gatString);
00899   
00900   gatType = GATString_GetType( gatString );
00901   GAT_TEST( GATType_GATString == gatType );
00902   
00903   GATString_Destroy( &gatString );
00904   
00905   GAT_TEST_STOP();
00906   return GATTrue;
00907 }
00908 
00909 static GATBool GATString_Clone_Test( void )
00910 {
00911   int           retval;
00912   FILE         *newFile;
00913   char          charset[41];
00914   char          encoding[41];
00915   int           lengthInBytes;
00916   FILE         *encodingFile;
00917   char          encodingFileName[256];
00918   GATBool       cloneEquals;
00919   GATString     gatString;
00920   const char   *newFileName;
00921   char          newTestName[256];
00922   unsigned char buffer[4];
00923   GATString     gatStringClone;
00924   unsigned int  i0, i1, i2, i3;
00925   
00926   sprintf(encodingFileName, "%s", ENCFILE);
00927 
00928   /* Open encoding file */
00929   encodingFile = fopen( encodingFileName, "r" );
00930   GAT_TEST( NULL != encodingFile );
00931   
00932   /* Get next encoding */
00933   while( NULL != fgets(encoding, 41, encodingFile) )
00934   {
00935     /* remove the trailing '\n' */
00936     char *eol = strchr(encoding, '\n');
00937     
00938     if (NULL != eol)
00939     {
00940       *eol = '\0';
00941     }
00942     
00943     /* Create new file name */
00944     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
00945     GAT_TEST (newFileName);
00946     
00947     sprintf        (newTestName, "GATString Clone Test: %s", encoding);
00948     GAT_TEST_START (newTestName);
00949 
00950     
00951     /* Open new file */
00952     newFile = fopen( newFileName, "r" );
00953     GAT_TEST( NULL != newFile );
00954     
00955     /* Read in length in bytes */
00956     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
00957     {
00958       if( 1 == lengthInBytes )
00959       {
00960         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &charset);
00961         GAT_TEST( EOF != retval );
00962         
00963         buffer[0] = i0;
00964         
00965         gatString = GATString_Create( (const char *) buffer, 1, charset );
00966         GAT_TEST( NULL != gatString);
00967         retval = GATString_Clone( gatString,  &gatStringClone );
00968         GAT_TEST( GAT_SUCCESS == retval );
00969         GAT_TEST( NULL != gatStringClone );
00970         
00971         retval = GATString_Equals( gatString, gatStringClone, &cloneEquals ); /* Note: Clone implicitly tests equals */
00972         GAT_TEST( GAT_SUCCESS == retval );
00973         GAT_TEST( GATTrue == cloneEquals );
00974         
00975         GATString_Destroy( &gatString ); /* Note: Clone implicitly tests destroy assuming we done leak memory */
00976         GATString_Destroy( &gatStringClone ); /* Note: Clone implicitly tests destroy assuming we done leak memory */
00977       }
00978       
00979       if( 2 == lengthInBytes )
00980       {
00981         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &charset);
00982         GAT_TEST( EOF != retval );
00983         
00984         buffer[0] = i0;
00985         buffer[1] = i1;
00986         
00987         gatString = GATString_Create( (const char *) buffer, 2, charset );
00988         GAT_TEST( NULL != gatString);
00989         retval = GATString_Clone( gatString,  &gatStringClone );
00990         GAT_TEST( GAT_SUCCESS == retval );
00991         GAT_TEST( NULL != gatStringClone );
00992         
00993         retval = GATString_Equals( gatString, gatStringClone, &cloneEquals ); /* Note: Clone implicitly tests equals */
00994         GAT_TEST( GAT_SUCCESS == retval );
00995         GAT_TEST( GATTrue == cloneEquals );
00996         
00997         GATString_Destroy( &gatString ); /* Note: Clone implicitly tests destroy assuming we done leak memory */
00998         GATString_Destroy( &gatStringClone ); /* Note: Clone implicitly tests destroy assuming we done leak memory */  
00999       }
01000       
01001       if( 3 == lengthInBytes )
01002       {
01003         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &charset);
01004         GAT_TEST( EOF != retval );
01005         
01006         buffer[0] = i0;
01007         buffer[1] = i1;
01008         buffer[2] = i2;
01009         
01010         gatString = GATString_Create( (const char *) buffer, 3, charset );
01011         GAT_TEST( NULL != gatString);
01012         retval = GATString_Clone( gatString,  &gatStringClone );
01013         GAT_TEST( GAT_SUCCESS == retval );
01014         GAT_TEST( NULL != gatStringClone );
01015         
01016         retval = GATString_Equals( gatString, gatStringClone, &cloneEquals ); /* Note: Clone implicitly tests equals */
01017         GAT_TEST( GAT_SUCCESS == retval );
01018         GAT_TEST( GATTrue == cloneEquals );
01019         
01020         GATString_Destroy( &gatString ); /* Note: Clone implicitly tests destroy assuming we done leak memory */
01021         GATString_Destroy( &gatStringClone ); /* Note: Clone implicitly tests destroy assuming we done leak memory */
01022       }
01023       
01024       if( 4 == lengthInBytes )
01025       {
01026         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &charset);
01027         GAT_TEST( EOF != retval );
01028         
01029         buffer[0] = i0;
01030         buffer[1] = i1;
01031         buffer[2] = i2;
01032         buffer[3] = i3;
01033         
01034         gatString = GATString_Create( (const char *) buffer, 4, charset );
01035         GAT_TEST( NULL != gatString);
01036         retval = GATString_Clone( gatString,  &gatStringClone );
01037         GAT_TEST( GAT_SUCCESS == retval );
01038         GAT_TEST( NULL != gatStringClone );
01039         
01040         retval = GATString_Equals( gatString, gatStringClone, &cloneEquals ); /* Note: Clone implicitly tests equals */
01041         GAT_TEST( GAT_SUCCESS == retval );
01042         GAT_TEST( GATTrue == cloneEquals );
01043         
01044         GATString_Destroy( &gatString ); /* Note: Clone implicitly tests destroy assuming we done leak memory */
01045         GATString_Destroy( &gatStringClone ); /* Note: Clone implicitly tests destroy assuming we done leak memory */       
01046       }
01047     }
01048 
01049     GAT_TEST_STOP ();
01050     
01051     /* Close new file */
01052     fclose( newFile );
01053   }
01054   
01055   /* Close encoding file */
01056   fclose( encodingFile );
01057   
01058   return GATTrue;
01059 }
01060 
01061 static GATBool GATString_Destroy_Test( void )
01062 {
01063   int           retval;
01064   FILE         *newFile;
01065   char          charset[41];
01066   char          encoding[41];
01067   int           lengthInBytes;
01068   FILE         *encodingFile;
01069   char          encodingFileName[256];
01070   GATString     gatString;
01071   const char   *newFileName;
01072   char          newTestName[256];
01073   unsigned char buffer[4];
01074   unsigned int  i0, i1, i2, i3;
01075   
01076   sprintf(encodingFileName, "%s", ENCFILE);
01077 
01078   /* Open encoding file */
01079   encodingFile = fopen( encodingFileName, "r" );
01080   GAT_TEST( NULL != encodingFile );
01081   
01082   /* Get next encoding */
01083   while( NULL != fgets(encoding, 41, encodingFile) )
01084   {
01085     /* remove the trailing '\n' */
01086     char *eol = strchr(encoding, '\n');
01087     
01088     if (NULL != eol)
01089     {
01090       *eol = '\0';
01091     }
01092     
01093     /* Create new file name */
01094     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
01095     GAT_TEST (newFileName);
01096     
01097     sprintf(newTestName, "GATString Destroy Test: %s", encoding);
01098     
01099     GAT_TEST_START(newTestName);
01100     
01101     /* Open new file */
01102     newFile = fopen( newFileName, "r" );
01103     GAT_TEST( NULL != newFile );
01104     
01105     /* Read in length in bytes */
01106     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01107     {
01108       if( 1 == lengthInBytes )
01109       {
01110         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &charset);
01111         GAT_TEST( EOF != retval );
01112         
01113         buffer[0] = i0;
01114         
01115         gatString = GATString_Create( (const char *) buffer, 1, charset ); /* Note: Destroy implicitly tests create */
01116         GAT_TEST( NULL != gatString);
01117         GATString_Destroy( &gatString ); 
01118       }
01119       
01120       if( 2 == lengthInBytes )
01121       {
01122         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &charset);
01123         GAT_TEST( EOF != retval );
01124         
01125         buffer[0] = i0;
01126         buffer[1] = i1;
01127         
01128         gatString = GATString_Create( (const char *) buffer, 2, charset ); /* Note: Destroy implicitly tests create */
01129         GAT_TEST( NULL != gatString);  
01130         GATString_Destroy( &gatString ); 
01131       }
01132       
01133       if( 3 == lengthInBytes )
01134       {
01135         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &charset);
01136         GAT_TEST( EOF != retval );
01137         
01138         buffer[0] = i0;
01139         buffer[1] = i1;
01140         buffer[2] = i2;
01141         
01142         gatString = GATString_Create( (const char *) buffer, 3, charset ); /* Note: Destroy implicitly tests create */
01143         GAT_TEST( NULL != gatString);        
01144         GATString_Destroy( &gatString );
01145       }
01146       
01147       if( 4 == lengthInBytes )
01148       {
01149         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &charset);
01150         GAT_TEST( EOF != retval );
01151         
01152         buffer[0] = i0;
01153         buffer[1] = i1;
01154         buffer[2] = i2;
01155         buffer[3] = i3;
01156         
01157         gatString = GATString_Create( (const char *) buffer, 4, charset ); /* Note: Destroy implicitly tests create */
01158         GAT_TEST( NULL != gatString);  
01159         GATString_Destroy( &gatString );      
01160       }
01161     }
01162 
01163     GAT_TEST_STOP ();
01164     
01165     /* Close new file */
01166     fclose( newFile );
01167   }
01168   
01169   /* Close encoding file */
01170   fclose( encodingFile );
01171   
01172   return GATTrue;
01173 }
01174 
01175 static GATBool GATString_GetLengthInBytes_Test( void )
01176 {
01177   int           retval;
01178   FILE         *newFile;
01179   char          charset[41];
01180   char          encoding[41];
01181   int           lengthInBytes;
01182   FILE         *encodingFile;
01183   char          encodingFileName[256];
01184   GATString     gatString;
01185   const char   *newFileName;
01186   char          newTestName[256];
01187   unsigned char buffer[4];
01188   unsigned int  i0, i1, i2, i3;
01189   GATuint32     returnedLengthInBytes;
01190   
01191   sprintf(encodingFileName, "%s", ENCFILE);
01192 
01193   /* Open encoding file */
01194   encodingFile = fopen( encodingFileName, "r" );
01195   GAT_TEST( NULL != encodingFile );
01196   
01197   /* Get next encoding */
01198   while( NULL != fgets(encoding, 41, encodingFile) )
01199   {
01200     /* remove the trailing '\n' */
01201     char *eol = strchr(encoding, '\n');
01202     
01203     if (NULL != eol)
01204     {
01205       *eol = '\0';
01206     }
01207     
01208     /* Create new file name */
01209     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
01210     GAT_TEST (newFileName);
01211 
01212     sprintf(newTestName, "GATString GetLengthInBytes Test: %s", encoding);
01213     
01214     GAT_TEST_START(newTestName);
01215 
01216     /* Open new file */
01217     newFile = fopen( newFileName, "r" );
01218     GAT_TEST( NULL != newFile );
01219     
01220     /* Read in length in bytes */
01221     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01222     {
01223       if( 1 == lengthInBytes )
01224       {
01225         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &charset);
01226         GAT_TEST( EOF != retval );
01227         
01228         buffer[0] = i0;
01229         
01230         gatString = GATString_Create( (const char *) buffer, 1, charset ); /* Note: Get_Length implicitly tests create */
01231         GAT_TEST( NULL != gatString);
01232         returnedLengthInBytes = GATString_GetLengthInBytes( gatString );
01233         GAT_TEST( 1 == returnedLengthInBytes );
01234         GATString_Destroy( &gatString ); /* Note: Get_Length implicitly tests destroy */
01235       }
01236       
01237       if( 2 == lengthInBytes )
01238       {
01239         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &charset);
01240         GAT_TEST( EOF != retval );
01241         
01242         buffer[0] = i0;
01243         buffer[1] = i1;
01244         
01245         gatString = GATString_Create( (const char *) buffer, 2, charset ); /* Note: Get_Length implicitly tests create */
01246         GAT_TEST( NULL != gatString);  
01247         returnedLengthInBytes = GATString_GetLengthInBytes( gatString );
01248         GAT_TEST( 2 == returnedLengthInBytes );
01249         GATString_Destroy( &gatString ); /* Note: Get_Length implicitly tests destroy */
01250       }
01251       
01252       if( 3 == lengthInBytes )
01253       {
01254         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &charset);
01255         GAT_TEST( EOF != retval );
01256         
01257         buffer[0] = i0;
01258         buffer[1] = i1;
01259         buffer[2] = i2;
01260         
01261         gatString = GATString_Create( (const char *) buffer, 3, charset ); /* Note: Get_Length implicitly tests create */
01262         GAT_TEST( NULL != gatString);  
01263         returnedLengthInBytes = GATString_GetLengthInBytes( gatString );
01264         GAT_TEST( 3 == returnedLengthInBytes );      
01265         GATString_Destroy( &gatString ); /* Note: Get_Length implicitly tests destroy */
01266       }
01267       
01268       if( 4 == lengthInBytes )
01269       {
01270         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &charset);
01271         GAT_TEST( EOF != retval );
01272         
01273         buffer[0] = i0;
01274         buffer[1] = i1;
01275         buffer[2] = i2;
01276         buffer[3] = i3;
01277         
01278         gatString = GATString_Create( (const char *) buffer, 4, charset ); /* Note: Get_Length implicitly tests create */
01279         GAT_TEST( NULL != gatString);  
01280         returnedLengthInBytes = GATString_GetLengthInBytes( gatString );
01281         GAT_TEST( 4 == returnedLengthInBytes );
01282         GATString_Destroy( &gatString ); /* Note: Get_Length implicitly tests destroy */ 
01283       }
01284     }
01285   
01286     GAT_TEST_STOP ();
01287     
01288     /* Close new file */
01289     fclose( newFile );
01290   }
01291 
01292   /* Close encoding file */
01293   fclose( encodingFile );
01294   
01295   return GATTrue;
01296 }
01297 
01298 static GATBool GATString_GetBuffer_Test( void )
01299 {
01300   int            retval;
01301   FILE          *newFile;
01302   char           charset[41];
01303   char           encoding[41];
01304   int            lengthInBytes;
01305   FILE          *encodingFile;
01306   char           encodingFileName[256];
01307   GATString      gatString;
01308   const char    *newFileName;
01309   char           newTestName[256];
01310   unsigned char  buffer[4];
01311   const char    *returnedBuffer;
01312   unsigned int   i0, i1, i2, i3;
01313   
01314   sprintf(encodingFileName, "%s", ENCFILE);
01315 
01316   /* Open encoding file */
01317   encodingFile = fopen( encodingFileName, "r" );
01318   GAT_TEST( NULL != encodingFile );
01319   
01320   /* Get next encoding */
01321   while( NULL != fgets(encoding, 41, encodingFile) )
01322   {
01323     /* remove the trailing '\n' */
01324     char *eol = strchr(encoding, '\n');
01325     
01326     if (NULL != eol)
01327     {
01328       *eol = '\0';
01329     }
01330     
01331     /* Create new file name */
01332     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
01333     GAT_TEST (newFileName);
01334 
01335     sprintf(newTestName, "GATString GetBuffer Test: %s", encoding);
01336   
01337     GAT_TEST_START(newTestName);
01338     
01339     /* Open new file */
01340     newFile = fopen( newFileName, "r" );
01341     GAT_TEST( NULL != newFile );
01342     
01343     /* Read in length in bytes */
01344     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01345     {
01346       if( 1 == lengthInBytes )
01347       {
01348         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &charset);
01349         GAT_TEST( EOF != retval );
01350         
01351         buffer[0] = i0;
01352         
01353         gatString = GATString_Create( (const char *) buffer, 1, charset ); /* Note: GetBuffer implicitly tests create */
01354         GAT_TEST( NULL != gatString);
01355         returnedBuffer = GATString_GetBuffer( gatString );
01356         GAT_TEST( NULL != returnedBuffer );
01357         retval = memcmp( (const void *) buffer, (const void *) returnedBuffer, 1 );
01358         GAT_TEST( 0 == retval );
01359         GATString_Destroy( &gatString ); /* Note: GetBuffer implicitly tests destroy */
01360       }
01361       
01362       if( 2 == lengthInBytes )
01363       {
01364         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &charset);
01365         GAT_TEST( EOF != retval );
01366         
01367         buffer[0] = i0;
01368         buffer[1] = i1;
01369         
01370         gatString = GATString_Create( (const char *) buffer, 2, charset ); /* Note: GetBuffer implicitly tests create */
01371         GAT_TEST( NULL != gatString);  
01372         returnedBuffer = GATString_GetBuffer( gatString );
01373         GAT_TEST( NULL != returnedBuffer );
01374         retval = memcmp( (const void *) buffer, (const void *) returnedBuffer, 2 );
01375         GAT_TEST( 0 == retval );
01376         GATString_Destroy( &gatString ); /* Note: GetBuffer implicitly tests destroy */
01377       }
01378       
01379       if( 3 == lengthInBytes )
01380       {
01381         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &charset);
01382         GAT_TEST( EOF != retval );
01383         
01384         buffer[0] = i0;
01385         buffer[1] = i1;
01386         buffer[2] = i2;
01387         
01388         gatString = GATString_Create( (const char *) buffer, 3, charset ); /* Note: GetBuffer implicitly tests create */
01389         GAT_TEST( NULL != gatString);  
01390         returnedBuffer = GATString_GetBuffer( gatString );
01391         GAT_TEST( NULL != returnedBuffer );
01392         retval = memcmp( (const void *) buffer, (const void *) returnedBuffer, 3 );
01393         GAT_TEST( 0 == retval );      
01394         GATString_Destroy( &gatString ); /* Note: GetBuffer implicitly tests destroy */
01395       }
01396       
01397       if( 4 == lengthInBytes )
01398       {
01399         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &charset);
01400         GAT_TEST( EOF != retval );
01401         
01402         buffer[0] = i0;
01403         buffer[1] = i1;
01404         buffer[2] = i2;
01405         buffer[3] = i3;
01406         
01407         gatString = GATString_Create( (const char *) buffer, 4, charset ); /* Note: GetBuffer implicitly tests create */
01408         GAT_TEST( NULL != gatString);  
01409         returnedBuffer = GATString_GetBuffer( gatString );
01410         GAT_TEST( NULL != returnedBuffer );
01411         retval = memcmp( (const void *) buffer, (const void *) returnedBuffer, 4 );
01412         GAT_TEST( 0 == retval );
01413         GATString_Destroy( &gatString ); /* Note: GetBuffer implicitly tests destroy */ 
01414       }
01415     }
01416   
01417     GAT_TEST_STOP ();
01418     
01419     /* Close new file */
01420     fclose( newFile );
01421   }
01422   
01423   /* Close encoding file */
01424   fclose( encodingFile );
01425   
01426   return GATTrue;
01427 }
01428 
01429 static GATBool GATString_GetEncoding_Test( void )
01430 {
01431   int            retval;
01432   FILE          *newFile;
01433   char           charset[41];
01434   char           encoding[41];
01435   int            lengthInBytes;
01436   FILE          *encodingFile;
01437   char           encodingFileName[256];
01438   GATString      gatString;
01439   const char    *newFileName;
01440   char           newTestName[256];
01441   unsigned char  buffer[4];
01442   unsigned int   i0, i1, i2, i3;
01443   const char    *returnedEncoding;
01444   
01445   sprintf(encodingFileName, "%s", ENCFILE);
01446 
01447   /* Open encoding file */
01448   encodingFile = fopen( encodingFileName, "r" );
01449   GAT_TEST( NULL != encodingFile );
01450   
01451   /* Get next encoding */
01452   while( NULL != fgets(encoding, 41, encodingFile) )
01453   {
01454     /* remove the trailing '\n' */
01455     char *eol = strchr(encoding, '\n');
01456     
01457     if (NULL != eol)
01458     {
01459       *eol = '\0';
01460     }
01461     
01462     /* Create new file name */
01463     newFileName = GATTest_GetTempFileNameF ("gat_%s", encoding);
01464     GAT_TEST (newFileName);
01465 
01466     sprintf(newTestName, "GATString GetEncoding Test: %s", encoding);
01467   
01468     GAT_TEST_START(newTestName);
01469     
01470     /* Open new file */
01471     newFile = fopen( newFileName, "r" );
01472     GAT_TEST( NULL != newFile );
01473     
01474     /* Read in length in bytes */
01475     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01476     {
01477       if( 1 == lengthInBytes )
01478       {
01479         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &charset);
01480         GAT_TEST( EOF != retval );
01481         
01482         buffer[0] = i0;
01483         
01484         gatString = GATString_Create( (const char *) buffer, 1, charset ); /* Note: GetEncoding implicitly tests create */
01485         GAT_TEST( NULL != gatString);
01486         returnedEncoding = GATString_GetEncoding( gatString );
01487         GAT_TEST( NULL != returnedEncoding );
01488         retval = strcmp( (const char *) charset, returnedEncoding );
01489         GAT_TEST( 0 == retval );
01490         GATString_Destroy( &gatString ); /* Note: GetEncoding implicitly tests destroy */
01491       }
01492       
01493       if( 2 == lengthInBytes )
01494       {
01495         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &charset);
01496         GAT_TEST( EOF != retval );
01497         
01498         buffer[0] = i0;
01499         buffer[1] = i1;
01500         
01501         gatString = GATString_Create( (const char *) buffer, 2, charset ); /* Note: GetEncoding implicitly tests create */
01502         GAT_TEST( NULL != gatString);  
01503         returnedEncoding = GATString_GetEncoding( gatString );
01504         GAT_TEST( NULL != returnedEncoding );
01505         retval = strcmp( (const char *) charset, returnedEncoding );
01506         GAT_TEST( 0 == retval );
01507         GATString_Destroy( &gatString ); /* Note: GetEncoding implicitly tests destroy */
01508       }
01509       
01510       if( 3 == lengthInBytes )
01511       {
01512         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &charset);
01513         GAT_TEST( EOF != retval );
01514         
01515         buffer[0] = i0;
01516         buffer[1] = i1;
01517         buffer[2] = i2;
01518         
01519         gatString = GATString_Create( (const char *) buffer, 3, charset ); /* Note: GetEncoding implicitly tests create */
01520         GAT_TEST( NULL != gatString);  
01521         returnedEncoding = GATString_GetEncoding( gatString );
01522         GAT_TEST( NULL != returnedEncoding );
01523         retval = strcmp( (const char *) charset, returnedEncoding );
01524         GAT_TEST( 0 == retval );      
01525         GATString_Destroy( &gatString ); /* Note: GetEncoding implicitly tests destroy */
01526       }
01527       
01528       if( 4 == lengthInBytes )
01529       {
01530         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &charset);
01531         GAT_TEST( EOF != retval );
01532         
01533         buffer[0] = i0;
01534         buffer[1] = i1;
01535         buffer[2] = i2;
01536         buffer[3] = i3;
01537         
01538         gatString = GATString_Create( (const char *) buffer, 4, charset ); /* Note: GetEncoding implicitly tests create */
01539         GAT_TEST( NULL != gatString);  
01540         returnedEncoding = GATString_GetEncoding( gatString );
01541         GAT_TEST( NULL != returnedEncoding );
01542         retval = strcmp( (const char *) charset, returnedEncoding );
01543         GAT_TEST( 0 == retval );
01544         GATString_Destroy( &gatString ); /* Note: GetEncoding implicitly tests destroy */ 
01545       }
01546     }
01547   
01548     GAT_TEST_STOP ();
01549     
01550     /* Close new file */
01551     fclose( newFile );
01552   }
01553   
01554   /* Close encoding file */
01555   fclose( encodingFile );
01556   
01557   return GATTrue;
01558 }
01559 
01560 static GATBool GATString_Translate_Test( void )
01561 {
01562   int            retval;
01563   FILE          *newFile;
01564   GATBool        isEqual;
01565   char           encoding[41];
01566   int            lengthInBytes;
01567   FILE          *encodingFile;
01568   char           encodingFileName[256];
01569   unsigned char  unicode[4];
01570   const char    *newFileName;
01571   char           newTestName[256];
01572   unsigned char  buffer[4];
01573   GATString      gatSourceString;
01574   GATString      gatTargetString;
01575   unsigned int   i0, i1, i2, i3;
01576   GATString      gatTranslatedString;
01577   
01578   sprintf(encodingFileName, "%s", ENCFILE);
01579 
01580   /* Open encoding file */
01581   encodingFile = fopen( encodingFileName, "r" );
01582   GAT_TEST( NULL != encodingFile );
01583   
01584   /* Get next encoding */
01585   while( NULL != fgets(encoding, 41, encodingFile) )
01586   {
01587     /* remove the trailing '\n' */
01588     char *eol = strchr(encoding, '\n');
01589     
01590     if (NULL != eol)
01591     {
01592       *eol = '\0';
01593     }
01594     
01595     /* Create new file name */
01596     newFileName = GATTest_GetTempFileNameF ("gat_%s_To_UCS_4_INTERNAL", encoding);
01597     GAT_TEST (newFileName);
01598 
01599     sprintf(newTestName, "GATString Translate Test: %s to UCS_4_INTERNAL", encoding);
01600     
01601     GAT_TEST_START(newTestName);
01602 
01603     
01604     /* Open new file */
01605     printf( "About too open file: %s\n", newFileName );
01606     fflush( stdout );
01607     newFile = fopen( newFileName, "r" );
01608     GAT_TEST( NULL != newFile );
01609     printf( "Opened file: %s\n", newFileName );
01610     fflush( stdout );
01611     
01612     /* Read in length in bytes */
01613     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01614     {
01615       if( 1 == lengthInBytes )
01616       {
01617         retval = fscanf(newFile, "0x%02X\t0x%02X%02X%02X%02X\n", &i0, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01618         GAT_TEST( EOF != retval );
01619         
01620         buffer[0] = i0;
01621         
01622         gatSourceString = GATString_Create( (const char *) buffer, 1, encoding );
01623         GAT_TEST( NULL != gatSourceString);
01624         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01625         GAT_TEST( NULL != gatTargetString);
01626         retval = GATString_Translate( gatSourceString, "UCS-4-INTERNAL", &gatTranslatedString );
01627         GAT_TEST( GAT_SUCCESS == retval );
01628         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01629         GAT_TEST( GAT_SUCCESS == retval );
01630         GAT_TEST( GATTrue == isEqual );
01631 
01632         GATString_Destroy( &gatSourceString );
01633         GATString_Destroy( &gatTargetString );
01634         GATString_Destroy( &gatTranslatedString );
01635       }
01636       
01637       if( 2 == lengthInBytes )
01638       {
01639         retval = fscanf(newFile, "0x%02X%02X\t0x%02X%02X%02X%02X\n", &i0, &i1, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01640         GAT_TEST( EOF != retval );
01641         
01642         buffer[0] = i0;
01643         buffer[1] = i1;
01644         
01645         gatSourceString = GATString_Create( (const char *) buffer, 2, encoding );
01646         GAT_TEST( NULL != gatSourceString);
01647         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01648         GAT_TEST( NULL != gatTargetString);
01649         retval = GATString_Translate( gatSourceString, "UCS-4-INTERNAL", &gatTranslatedString );
01650         GAT_TEST( GAT_SUCCESS == retval );
01651         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01652         GAT_TEST( GAT_SUCCESS == retval );
01653         GAT_TEST( GATTrue == isEqual );
01654 
01655         GATString_Destroy( &gatSourceString );
01656         GATString_Destroy( &gatTargetString );
01657         GATString_Destroy( &gatTranslatedString );
01658       }
01659       
01660       if( 3 == lengthInBytes )
01661       {
01662         retval = fscanf(newFile, "0x%02X%02X%02X\t0x%02X%02X%02X%02X\n", &i0, &i1, &i2, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01663         GAT_TEST( EOF != retval );
01664         
01665         buffer[0] = i0;
01666         buffer[1] = i1;
01667         buffer[2] = i2;
01668         
01669         gatSourceString = GATString_Create( (const char *) buffer, 3, encoding );
01670         GAT_TEST( NULL != gatSourceString);
01671         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01672         GAT_TEST( NULL != gatTargetString);
01673         retval = GATString_Translate( gatSourceString, "UCS-4-INTERNAL", &gatTranslatedString );
01674         GAT_TEST( GAT_SUCCESS == retval );
01675         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01676         GAT_TEST( GAT_SUCCESS == retval );
01677         GAT_TEST( GATTrue == isEqual );
01678 
01679         GATString_Destroy( &gatSourceString );
01680         GATString_Destroy( &gatTargetString );
01681         GATString_Destroy( &gatTranslatedString );
01682       }
01683       
01684       if( 4 == lengthInBytes )
01685       {        
01686         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t0x%02X%02X%02X%02X\n", &i0, &i1, &i2, &i3, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01687         GAT_TEST( EOF != retval );
01688         
01689         buffer[0] = i0;
01690         buffer[1] = i1;
01691         buffer[2] = i2;
01692         buffer[3] = i3;
01693         
01694         gatSourceString = GATString_Create( (const char *) buffer, 4, encoding );
01695         GAT_TEST( NULL != gatSourceString);
01696         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01697         GAT_TEST( NULL != gatTargetString);
01698         retval = GATString_Translate( gatSourceString, "UCS-4-INTERNAL", &gatTranslatedString );
01699         GAT_TEST( GAT_SUCCESS == retval );
01700         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01701         GAT_TEST( GAT_SUCCESS == retval );
01702         GAT_TEST( GATTrue == isEqual );
01703 
01704         GATString_Destroy( &gatSourceString );
01705         GATString_Destroy( &gatTargetString );
01706         GATString_Destroy( &gatTranslatedString );
01707       }
01708     }
01709     
01710     /* Close new file */
01711     fclose( newFile );
01712     
01713     /* Create new file name */
01714     newFileName = GATTest_GetTempFileNameF ("gat_UCS_4_INTERNAL_To_%s", encoding);
01715     GAT_TEST (newFileName);
01716 
01717     
01718     /* Open new file */
01719     newFile = fopen( newFileName, "r" );
01720     GAT_TEST( NULL != newFile );
01721     
01722     /* Read in length in bytes */
01723     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01724     {
01725       if( 1 == lengthInBytes )
01726       {
01727         retval = fscanf(newFile, "0x%02X\t0x%02X%02X%02X%02X\n", &i0,
01728                                   &unicode[0], &unicode[1], 
01729                                   &unicode[2], &unicode[3]);
01730         GAT_TEST( EOF != retval );
01731         
01732         buffer[0] = i0;
01733         
01734         gatTargetString = GATString_Create( (const char *) buffer, 1, encoding );
01735         GAT_TEST( NULL != gatTargetString);
01736         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01737         GAT_TEST( NULL != gatSourceString);
01738         retval = GATString_Translate( gatSourceString, encoding, &gatTranslatedString );
01739         GAT_TEST( GAT_SUCCESS == retval );
01740         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01741         GAT_TEST( GAT_SUCCESS == retval );
01742         GAT_TEST( GATTrue == isEqual );
01743 
01744         GATString_Destroy( &gatSourceString );
01745         GATString_Destroy( &gatTargetString );
01746         GATString_Destroy( &gatTranslatedString );
01747       }
01748      
01749       if( 2 == lengthInBytes )
01750       {
01751         retval = fscanf(newFile, "0x%02X%02X\t0x%02X%02X%02X%02X\n", &i0, &i1, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01752         GAT_TEST( EOF != retval );
01753         
01754         buffer[0] = i0;
01755         buffer[1] = i1;
01756         
01757         gatTargetString = GATString_Create( (const char *) buffer, 2, encoding );
01758         GAT_TEST( NULL != gatTargetString);
01759         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01760         GAT_TEST( NULL != gatSourceString);
01761         retval = GATString_Translate( gatSourceString, encoding, &gatTranslatedString );
01762         GAT_TEST( GAT_SUCCESS == retval );
01763         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01764         GAT_TEST( GAT_SUCCESS == retval );
01765         GAT_TEST( GATTrue == isEqual );
01766 
01767         GATString_Destroy( &gatSourceString );
01768         GATString_Destroy( &gatTargetString );
01769         GATString_Destroy( &gatTranslatedString );
01770       }
01771       
01772       if( 3 == lengthInBytes )
01773       {
01774         retval = fscanf(newFile, "0x%02X%02X%02X\t0x%02X%02X%02X%02X\n", &i0, &i1, &i2, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01775         GAT_TEST( EOF != retval );
01776         
01777         buffer[0] = i0;
01778         buffer[1] = i1;
01779         buffer[2] = i2;
01780         
01781         gatTargetString = GATString_Create( (const char *) buffer, 3, encoding );
01782         GAT_TEST( NULL != gatTargetString);
01783         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01784         GAT_TEST( NULL != gatSourceString);
01785         retval = GATString_Translate( gatSourceString, encoding, &gatTranslatedString );
01786         GAT_TEST( GAT_SUCCESS == retval );
01787         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01788         GAT_TEST( GAT_SUCCESS == retval );
01789         GAT_TEST( GATTrue == isEqual );
01790 
01791         GATString_Destroy( &gatSourceString );
01792         GATString_Destroy( &gatTargetString );
01793         GATString_Destroy( &gatTranslatedString );
01794       }
01795       
01796       if( 4 == lengthInBytes )
01797       {        
01798         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t0x%02X%02X%02X%02X\n", &i0, &i1, &i2, &i3, &unicode[0], &unicode[1], &unicode[2], &unicode[3]);
01799         GAT_TEST( EOF != retval );
01800         
01801         buffer[0] = i0;
01802         buffer[1] = i1;
01803         buffer[2] = i2;
01804         buffer[3] = i3;
01805         
01806         gatTargetString = GATString_Create( (const char *) buffer, 4, encoding );
01807         GAT_TEST( NULL != gatTargetString);
01808         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01809         GAT_TEST( NULL != gatSourceString);
01810         retval = GATString_Translate( gatSourceString, encoding, &gatTranslatedString );
01811         GAT_TEST( GAT_SUCCESS == retval );
01812         retval = GATString_Equals(gatTargetString, gatTranslatedString, &isEqual);
01813         GAT_TEST( GAT_SUCCESS == retval );
01814         GAT_TEST( GATTrue == isEqual );
01815 
01816         GATString_Destroy( &gatSourceString );
01817         GATString_Destroy( &gatTargetString );
01818         GATString_Destroy( &gatTranslatedString );
01819       }
01820     }
01821   
01822     GAT_TEST_STOP ();
01823     
01824     /* Close new file */
01825     fclose( newFile );    
01826   }
01827   
01828   /* Close encoding file */
01829   fclose( encodingFile );
01830   
01831   return GATTrue;
01832 }
01833 
01834 static GATBool GATString_CompareTo_Test( void )
01835 {
01836   int           retval;
01837   FILE         *newFile;
01838   int           comparrison;
01839 //GATBool       isEqual;
01840   char          encoding[41];
01841   int           lengthInBytes;
01842   FILE         *encodingFile;
01843   char          encodingFileName[256];
01844   char          unicode[256];
01845   const char   *newFileName;
01846   char          newTestName[256];
01847   unsigned char buffer[4];
01848   GATString     gatEmptyString;
01849   GATString     gatSourceString;
01850   GATString     gatTargetString;
01851   unsigned int  i0, i1, i2, i3;
01852   
01853   /* Create empty GATString */
01854   gatEmptyString = GATString_Create( "", 1, "ASCII" );
01855   GAT_TEST( NULL != gatEmptyString );
01856   
01857   sprintf(encodingFileName, "%s", ENCFILE);
01858 
01859   /* Open encoding file */
01860   encodingFile = fopen( encodingFileName, "r" );
01861   GAT_TEST( NULL != encodingFile );
01862   
01863   /* Get next encoding */
01864   while( NULL != fgets(encoding, 41, encodingFile) )
01865   {
01866     /* remove the trailing '\n' */
01867     char *eol = strchr(encoding, '\n');
01868     
01869     if (NULL != eol)
01870     {
01871       *eol = '\0';
01872     }
01873     
01874     /* Create new file name */
01875     newFileName = GATTest_GetTempFileNameF ("gat_%s_To_UCS_4_INTERNAL", encoding);
01876     GAT_TEST (newFileName);
01877 
01878     sprintf(newTestName, "GATString CompareTo Test: %s to UCS_4_INTERNAL", 
01879             encoding);
01880 
01881     GAT_TEST_START(newTestName);
01882 
01883     
01884     /* Open new file */
01885     newFile = fopen( newFileName, "r" );
01886     GAT_TEST( NULL != newFile );
01887     
01888     /* Read in length in bytes */
01889     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
01890     {
01891       if( 1 == lengthInBytes )
01892       {
01893         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &unicode);
01894         GAT_TEST( EOF != retval );
01895         
01896         buffer[0] = i0;
01897         
01898         gatSourceString = GATString_Create( (const char *) buffer, 1, encoding );
01899         GAT_TEST( NULL != gatSourceString);
01900         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01901         GAT_TEST( NULL != gatTargetString);
01902         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
01903         GAT_TEST( GAT_SUCCESS == retval );
01904         GAT_TEST( 0 == comparrison );
01905         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
01906         GAT_TEST( GAT_SUCCESS == retval );
01907         GAT_TEST( 0 > comparrison );
01908         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
01909         GAT_TEST( GAT_SUCCESS == retval );
01910         GAT_TEST( 0 < comparrison );
01911         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
01912         GAT_TEST( GAT_SUCCESS == retval );
01913         GAT_TEST( 0 > comparrison );
01914         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
01915         GAT_TEST( GAT_SUCCESS == retval );
01916         GAT_TEST( 0 < comparrison );
01917         
01918 
01919         GATString_Destroy( &gatSourceString );
01920         GATString_Destroy( &gatTargetString );
01921       }
01922       
01923       if( 2 == lengthInBytes )
01924       {
01925         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &unicode);
01926         GAT_TEST( EOF != retval );
01927         
01928         buffer[0] = i0;
01929         buffer[1] = i1;
01930         
01931         gatSourceString = GATString_Create( (const char *) buffer, 2, encoding );
01932         GAT_TEST( NULL != gatSourceString);
01933         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01934         GAT_TEST( NULL != gatTargetString);
01935         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
01936         GAT_TEST( GAT_SUCCESS == retval );
01937         GAT_TEST( 0 == comparrison );
01938         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
01939         GAT_TEST( GAT_SUCCESS == retval );
01940         GAT_TEST( 0 > comparrison );
01941         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
01942         GAT_TEST( GAT_SUCCESS == retval );
01943         GAT_TEST( 0 < comparrison );
01944         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
01945         GAT_TEST( GAT_SUCCESS == retval );
01946         GAT_TEST( 0 > comparrison );
01947         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
01948         GAT_TEST( GAT_SUCCESS == retval );
01949         GAT_TEST( 0 < comparrison );
01950 
01951         GATString_Destroy( &gatSourceString );
01952         GATString_Destroy( &gatTargetString );
01953       }
01954       
01955       if( 3 == lengthInBytes )
01956       {
01957         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &unicode);
01958         GAT_TEST( EOF != retval );
01959         
01960         buffer[0] = i0;
01961         buffer[1] = i1;
01962         buffer[2] = i2;
01963         
01964         gatSourceString = GATString_Create( (const char *) buffer, 3, encoding );
01965         GAT_TEST( NULL != gatSourceString);
01966         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
01967         GAT_TEST( NULL != gatTargetString);
01968         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
01969         GAT_TEST( GAT_SUCCESS == retval );
01970         GAT_TEST( 0 == comparrison );
01971         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
01972         GAT_TEST( GAT_SUCCESS == retval );
01973         GAT_TEST( 0 > comparrison );
01974         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
01975         GAT_TEST( GAT_SUCCESS == retval );
01976         GAT_TEST( 0 < comparrison );
01977         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
01978         GAT_TEST( GAT_SUCCESS == retval );
01979         GAT_TEST( 0 > comparrison );
01980         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
01981         GAT_TEST( GAT_SUCCESS == retval );
01982         GAT_TEST( 0 < comparrison );
01983 
01984         GATString_Destroy( &gatSourceString );
01985         GATString_Destroy( &gatTargetString );
01986       }
01987       
01988       if( 4 == lengthInBytes )
01989       {        
01990         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &unicode);
01991         GAT_TEST( EOF != retval );
01992         
01993         buffer[0] = i0;
01994         buffer[1] = i1;
01995         buffer[2] = i2;
01996         buffer[3] = i3;
01997         
01998         gatSourceString = GATString_Create( (const char *) buffer, 4, encoding );
01999         GAT_TEST( NULL != gatSourceString);
02000         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02001         GAT_TEST( NULL != gatTargetString);
02002         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
02003         GAT_TEST( GAT_SUCCESS == retval );
02004         GAT_TEST( 0 == comparrison );
02005         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
02006         GAT_TEST( GAT_SUCCESS == retval );
02007         GAT_TEST( 0 > comparrison );
02008         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
02009         GAT_TEST( GAT_SUCCESS == retval );
02010         GAT_TEST( 0 < comparrison );
02011         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
02012         GAT_TEST( GAT_SUCCESS == retval );
02013         GAT_TEST( 0 > comparrison );
02014         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
02015         GAT_TEST( GAT_SUCCESS == retval );
02016         GAT_TEST( 0 < comparrison );
02017 
02018         GATString_Destroy( &gatSourceString );
02019         GATString_Destroy( &gatTargetString );
02020       }
02021     }
02022     
02023     /* Close new file */
02024     fclose( newFile );
02025     
02026     /* Create new file name */
02027     newFileName = GATTest_GetTempFileNameF ("gat_UCS_4_INTERNAL_To_%s", encoding);
02028     GAT_TEST (newFileName);
02029 
02030     
02031     /* Open new file */
02032     newFile = fopen( newFileName, "r" );
02033     GAT_TEST( NULL != newFile );
02034     
02035     /* Read in length in bytes */
02036     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
02037     {
02038       if( 1 == lengthInBytes )
02039       {
02040         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &unicode);
02041         GAT_TEST( EOF != retval );
02042         
02043         buffer[0] = i0;
02044         
02045         gatTargetString = GATString_Create( (const char *) buffer, 1, encoding );
02046         GAT_TEST( NULL != gatTargetString);
02047         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02048         GAT_TEST( NULL != gatSourceString);
02049         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
02050         GAT_TEST( GAT_SUCCESS == retval );
02051         GAT_TEST( 0 == comparrison );
02052         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
02053         GAT_TEST( GAT_SUCCESS == retval );
02054         GAT_TEST( 0 > comparrison );
02055         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
02056         GAT_TEST( GAT_SUCCESS == retval );
02057         GAT_TEST( 0 < comparrison );
02058         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
02059         GAT_TEST( GAT_SUCCESS == retval );
02060         GAT_TEST( 0 > comparrison );
02061         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
02062         GAT_TEST( GAT_SUCCESS == retval );
02063         GAT_TEST( 0 < comparrison );
02064 
02065         GATString_Destroy( &gatSourceString );
02066         GATString_Destroy( &gatTargetString );
02067       }
02068      
02069       if( 2 == lengthInBytes )
02070       {
02071         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &unicode);
02072         GAT_TEST( EOF != retval );
02073         
02074         buffer[0] = i0;
02075         buffer[1] = i1;
02076         
02077         gatTargetString = GATString_Create( (const char *) buffer, 2, encoding );
02078         GAT_TEST( NULL != gatTargetString);
02079         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02080         GAT_TEST( NULL != gatSourceString);
02081         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
02082         GAT_TEST( GAT_SUCCESS == retval );
02083         GAT_TEST( 0 == comparrison );
02084         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
02085         GAT_TEST( GAT_SUCCESS == retval );
02086         GAT_TEST( 0 > comparrison );
02087         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
02088         GAT_TEST( GAT_SUCCESS == retval );
02089         GAT_TEST( 0 < comparrison );
02090         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
02091         GAT_TEST( GAT_SUCCESS == retval );
02092         GAT_TEST( 0 > comparrison );
02093         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
02094         GAT_TEST( GAT_SUCCESS == retval );
02095         GAT_TEST( 0 < comparrison );
02096 
02097         GATString_Destroy( &gatSourceString );
02098         GATString_Destroy( &gatTargetString );
02099       }
02100       
02101       if( 3 == lengthInBytes )
02102       {
02103         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &unicode);
02104         GAT_TEST( EOF != retval );
02105         
02106         buffer[0] = i0;
02107         buffer[1] = i1;
02108         buffer[2] = i2;
02109         
02110         gatTargetString = GATString_Create( (const char *) buffer, 3, encoding );
02111         GAT_TEST( NULL != gatTargetString);
02112         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02113         GAT_TEST( NULL != gatSourceString);
02114         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
02115         GAT_TEST( GAT_SUCCESS == retval );
02116         GAT_TEST( 0 == comparrison );
02117         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
02118         GAT_TEST( GAT_SUCCESS == retval );
02119         GAT_TEST( 0 > comparrison );
02120         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
02121         GAT_TEST( GAT_SUCCESS == retval );
02122         GAT_TEST( 0 < comparrison );
02123         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
02124         GAT_TEST( GAT_SUCCESS == retval );
02125         GAT_TEST( 0 > comparrison );
02126         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
02127         GAT_TEST( GAT_SUCCESS == retval );
02128         GAT_TEST( 0 < comparrison );
02129 
02130         GATString_Destroy( &gatSourceString );
02131         GATString_Destroy( &gatTargetString );
02132       }
02133       
02134       if( 4 == lengthInBytes )
02135       {        
02136         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &unicode);
02137         GAT_TEST( EOF != retval );
02138         
02139         buffer[0] = i0;
02140         buffer[1] = i1;
02141         buffer[2] = i2;
02142         buffer[3] = i3;
02143         
02144         gatTargetString = GATString_Create( (const char *) buffer, 4, encoding );
02145         GAT_TEST( NULL != gatTargetString);
02146         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02147         GAT_TEST( NULL != gatSourceString);
02148         retval = GATString_CompareTo(gatSourceString, gatTargetString, &comparrison);
02149         GAT_TEST( GAT_SUCCESS == retval );
02150         GAT_TEST( 0 == comparrison );
02151         retval = GATString_CompareTo(gatEmptyString, gatSourceString, &comparrison);
02152         GAT_TEST( GAT_SUCCESS == retval );
02153         GAT_TEST( 0 > comparrison );
02154         retval = GATString_CompareTo(gatSourceString, gatEmptyString, &comparrison);
02155         GAT_TEST( GAT_SUCCESS == retval );
02156         GAT_TEST( 0 < comparrison );
02157         retval = GATString_CompareTo(gatEmptyString, gatTargetString, &comparrison);
02158         GAT_TEST( GAT_SUCCESS == retval );
02159         GAT_TEST( 0 > comparrison );
02160         retval = GATString_CompareTo(gatTargetString, gatEmptyString, &comparrison);
02161         GAT_TEST( GAT_SUCCESS == retval );
02162         GAT_TEST( 0 < comparrison );
02163 
02164         GATString_Destroy( &gatSourceString );
02165         GATString_Destroy( &gatTargetString );
02166       }
02167     }
02168     
02169     GAT_TEST_STOP ();
02170   
02171     /* Close new file */
02172     fclose( newFile );    
02173   }
02174   
02175   /* Close encoding file */
02176   fclose( encodingFile );
02177   
02178   /* Destroy empty GATString */
02179   GATString_Destroy( &gatEmptyString );
02180   
02181   return GATTrue;
02182 }
02183 
02184 static GATBool GATString_EndsWith_Test( void )
02185 {
02186   int           retval;
02187   FILE         *newFile;
02188   GATBool       result;
02189 //GATBool       isEqual;
02190   char          encoding[41];
02191   int           lengthInBytes;
02192   FILE         *encodingFile;
02193   char          encodingFileName[256];
02194   char          unicode[256];
02195   const char   *newFileName;
02196   char          newTestName[256];
02197   unsigned char buffer[4];
02198   GATString     gatEmptyString;
02199   GATString     gatSourceString;
02200   GATString     gatTargetString;
02201   unsigned int  i0, i1, i2, i3;
02202   
02203   /* Create emptry GATString */
02204   gatEmptyString = GATString_Create( "", 1, "ASCII" );
02205   GAT_TEST( NULL != gatEmptyString );
02206   
02207   sprintf(encodingFileName, "%s", ENCFILE);
02208 
02209   /* Open encoding file */
02210   encodingFile = fopen( encodingFileName, "r" );
02211   GAT_TEST( NULL != encodingFile );
02212   
02213   /* Get next encoding */
02214   while( NULL != fgets(encoding, 41, encodingFile) )
02215   {
02216     /* remove the trailing '\n' */
02217     char *eol = strchr(encoding, '\n');
02218     
02219     if (NULL != eol)
02220     {
02221       *eol = '\0';
02222     }
02223     
02224     /* Create new file name */
02225     newFileName = GATTest_GetTempFileNameF ("gat_%s_To_UCS_4_INTERNAL", encoding);
02226     GAT_TEST (newFileName);
02227 
02228     sprintf(newTestName, "GATString EndsWith Test: %s to UCS_4_INTERNAL", 
02229             encoding);
02230   
02231     GAT_TEST_START(newTestName);
02232     
02233     /* Open new file */
02234     newFile = fopen( newFileName, "r" );
02235     GAT_TEST( NULL != newFile );
02236     
02237     /* Read in length in bytes */
02238     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
02239     {
02240       if( 1 == lengthInBytes )
02241       {
02242         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &unicode);
02243         GAT_TEST( EOF != retval );
02244         
02245         buffer[0] = i0;
02246         
02247         gatSourceString = GATString_Create( (const char *) buffer, 1, encoding );
02248         GAT_TEST( NULL != gatSourceString);
02249         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02250         GAT_TEST( NULL != gatTargetString);
02251         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02252         GAT_TEST( GAT_SUCCESS == retval );
02253         GAT_TEST( GATTrue == result );
02254         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02255         GAT_TEST( GAT_SUCCESS == retval );
02256         GAT_TEST( GATTrue == result );
02257         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02258         GAT_TEST( GAT_SUCCESS == retval );
02259         GAT_TEST( GATTrue == result );
02260         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02261         GAT_TEST( GAT_SUCCESS == retval );
02262         GAT_TEST( GATFalse == result );
02263         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02264         GAT_TEST( GAT_SUCCESS == retval );
02265         GAT_TEST( GATTrue == result );
02266         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02267         GAT_TEST( GAT_SUCCESS == retval );
02268         GAT_TEST( GATFalse == result );
02269 
02270         GATString_Destroy( &gatSourceString );
02271         GATString_Destroy( &gatTargetString );
02272       }
02273       
02274       if( 2 == lengthInBytes )
02275       {
02276         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &unicode);
02277         GAT_TEST( EOF != retval );
02278         
02279         buffer[0] = i0;
02280         buffer[1] = i1;
02281         
02282         gatSourceString = GATString_Create( (const char *) buffer, 2, encoding );
02283         GAT_TEST( NULL != gatSourceString);
02284         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02285         GAT_TEST( NULL != gatTargetString);
02286         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02287         GAT_TEST( GAT_SUCCESS == retval );
02288         GAT_TEST( GATTrue == result );
02289         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02290         GAT_TEST( GAT_SUCCESS == retval );
02291         GAT_TEST( GATTrue == result );
02292         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02293         GAT_TEST( GAT_SUCCESS == retval );
02294         GAT_TEST( GATTrue == result );
02295         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02296         GAT_TEST( GAT_SUCCESS == retval );
02297         GAT_TEST( GATFalse == result );
02298         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02299         GAT_TEST( GAT_SUCCESS == retval );
02300         GAT_TEST( GATTrue == result );
02301         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02302         GAT_TEST( GAT_SUCCESS == retval );
02303         GAT_TEST( GATFalse == result );
02304 
02305         GATString_Destroy( &gatSourceString );
02306         GATString_Destroy( &gatTargetString );
02307       }
02308       
02309       if( 3 == lengthInBytes )
02310       {
02311         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &unicode);
02312         GAT_TEST( EOF != retval );
02313         
02314         buffer[0] = i0;
02315         buffer[1] = i1;
02316         buffer[2] = i2;
02317         
02318         gatSourceString = GATString_Create( (const char *) buffer, 3, encoding );
02319         GAT_TEST( NULL != gatSourceString);
02320         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02321         GAT_TEST( NULL != gatTargetString);
02322         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02323         GAT_TEST( GAT_SUCCESS == retval );
02324         GAT_TEST( GATTrue == result );
02325         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02326         GAT_TEST( GAT_SUCCESS == retval );
02327         GAT_TEST( GATTrue == result );
02328         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02329         GAT_TEST( GAT_SUCCESS == retval );
02330         GAT_TEST( GATTrue == result );
02331         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02332         GAT_TEST( GAT_SUCCESS == retval );
02333         GAT_TEST( GATFalse == result );
02334         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02335         GAT_TEST( GAT_SUCCESS == retval );
02336         GAT_TEST( GATTrue == result );
02337         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02338         GAT_TEST( GAT_SUCCESS == retval );
02339         GAT_TEST( GATFalse == result );
02340 
02341         GATString_Destroy( &gatSourceString );
02342         GATString_Destroy( &gatTargetString );
02343       }
02344       
02345       if( 4 == lengthInBytes )
02346       {        
02347         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &unicode);
02348         GAT_TEST( EOF != retval );
02349         
02350         buffer[0] = i0;
02351         buffer[1] = i1;
02352         buffer[2] = i2;
02353         buffer[3] = i3;
02354         
02355         gatSourceString = GATString_Create( (const char *) buffer, 4, encoding );
02356         GAT_TEST( NULL != gatSourceString);
02357         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02358         GAT_TEST( NULL != gatTargetString);
02359         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02360         GAT_TEST( GAT_SUCCESS == retval );
02361         GAT_TEST( GATTrue == result );
02362         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02363         GAT_TEST( GAT_SUCCESS == retval );
02364         GAT_TEST( GATTrue == result );
02365         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02366         GAT_TEST( GAT_SUCCESS == retval );
02367         GAT_TEST( GATTrue == result );
02368         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02369         GAT_TEST( GAT_SUCCESS == retval );
02370         GAT_TEST( GATFalse == result );
02371         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02372         GAT_TEST( GAT_SUCCESS == retval );
02373         GAT_TEST( GATTrue == result );
02374         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02375         GAT_TEST( GAT_SUCCESS == retval );
02376         GAT_TEST( GATFalse == result );
02377 
02378         GATString_Destroy( &gatSourceString );
02379         GATString_Destroy( &gatTargetString );
02380       }
02381     }
02382     
02383     /* Close new file */
02384     fclose( newFile );
02385     
02386     /* Create new file name */
02387     newFileName = GATTest_GetTempFileNameF ("gat_UCS_4_INTERNAL_To_%s", encoding);
02388     GAT_TEST (newFileName);
02389 
02390     
02391     /* Open new file */
02392     newFile = fopen( newFileName, "r" );
02393     GAT_TEST( NULL != newFile );
02394     
02395     /* Read in length in bytes */
02396     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
02397     {
02398       if( 1 == lengthInBytes )
02399       {
02400         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &unicode);
02401         GAT_TEST( EOF != retval );
02402         
02403         buffer[0] = i0;
02404         
02405         gatTargetString = GATString_Create( (const char *) buffer, 1, encoding );
02406         GAT_TEST( NULL != gatTargetString);
02407         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02408         GAT_TEST( NULL != gatSourceString);
02409         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02410         GAT_TEST( GAT_SUCCESS == retval );
02411         GAT_TEST( GATTrue == result );
02412         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02413         GAT_TEST( GAT_SUCCESS == retval );
02414         GAT_TEST( GATTrue == result );
02415         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02416         GAT_TEST( GAT_SUCCESS == retval );
02417         GAT_TEST( GATTrue == result );
02418         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02419         GAT_TEST( GAT_SUCCESS == retval );
02420         GAT_TEST( GATFalse == result );
02421         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02422         GAT_TEST( GAT_SUCCESS == retval );
02423         GAT_TEST( GATTrue == result );
02424         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02425         GAT_TEST( GAT_SUCCESS == retval );
02426         GAT_TEST( GATFalse == result );
02427 
02428         GATString_Destroy( &gatSourceString );
02429         GATString_Destroy( &gatTargetString );
02430       }
02431      
02432       if( 2 == lengthInBytes )
02433       {
02434         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &unicode);
02435         GAT_TEST( EOF != retval );
02436         
02437         buffer[0] = i0;
02438         buffer[1] = i1;
02439         
02440         gatTargetString = GATString_Create( (const char *) buffer, 2, encoding );
02441         GAT_TEST( NULL != gatTargetString);
02442         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02443         GAT_TEST( NULL != gatSourceString);
02444         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02445         GAT_TEST( GAT_SUCCESS == retval );
02446         GAT_TEST( GATTrue == result );
02447         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02448         GAT_TEST( GAT_SUCCESS == retval );
02449         GAT_TEST( GATTrue == result );
02450         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02451         GAT_TEST( GAT_SUCCESS == retval );
02452         GAT_TEST( GATTrue == result );
02453         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02454         GAT_TEST( GAT_SUCCESS == retval );
02455         GAT_TEST( GATFalse == result );
02456         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02457         GAT_TEST( GAT_SUCCESS == retval );
02458         GAT_TEST( GATTrue == result );
02459         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02460         GAT_TEST( GAT_SUCCESS == retval );
02461         GAT_TEST( GATFalse == result );
02462 
02463         GATString_Destroy( &gatSourceString );
02464         GATString_Destroy( &gatTargetString );
02465       }
02466       
02467       if( 3 == lengthInBytes )
02468       {
02469         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &unicode);
02470         GAT_TEST( EOF != retval );
02471         
02472         buffer[0] = i0;
02473         buffer[1] = i1;
02474         buffer[2] = i2;
02475         
02476         gatTargetString = GATString_Create( (const char *) buffer, 3, encoding );
02477         GAT_TEST( NULL != gatTargetString);
02478         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02479         GAT_TEST( NULL != gatSourceString);
02480         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02481         GAT_TEST( GAT_SUCCESS == retval );
02482         GAT_TEST( GATTrue == result );
02483         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02484         GAT_TEST( GAT_SUCCESS == retval );
02485         GAT_TEST( GATTrue == result );
02486         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02487         GAT_TEST( GAT_SUCCESS == retval );
02488         GAT_TEST( GATTrue == result );
02489         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02490         GAT_TEST( GAT_SUCCESS == retval );
02491         GAT_TEST( GATFalse == result );
02492         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02493         GAT_TEST( GAT_SUCCESS == retval );
02494         GAT_TEST( GATTrue == result );
02495         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02496         GAT_TEST( GAT_SUCCESS == retval );
02497         GAT_TEST( GATFalse == result );
02498 
02499         GATString_Destroy( &gatSourceString );
02500         GATString_Destroy( &gatTargetString );
02501       }
02502       
02503       if( 4 == lengthInBytes )
02504       {        
02505         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &unicode);
02506         GAT_TEST( EOF != retval );
02507         
02508         buffer[0] = i0;
02509         buffer[1] = i1;
02510         buffer[2] = i2;
02511         buffer[3] = i3;
02512         
02513         gatTargetString = GATString_Create( (const char *) buffer, 4, encoding );
02514         GAT_TEST( NULL != gatTargetString);
02515         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02516         GAT_TEST( NULL != gatSourceString);
02517         retval = GATString_EndsWith(gatSourceString, gatTargetString, &result);
02518         GAT_TEST( GAT_SUCCESS == retval );
02519         GAT_TEST( GATTrue == result );
02520         retval = GATString_EndsWith(gatTargetString, gatSourceString, &result);
02521         GAT_TEST( GAT_SUCCESS == retval );
02522         GAT_TEST( GATTrue == result );
02523         retval = GATString_EndsWith(gatSourceString, gatEmptyString, &result);
02524         GAT_TEST( GAT_SUCCESS == retval );
02525         GAT_TEST( GATTrue == result );
02526         retval = GATString_EndsWith(gatEmptyString, gatSourceString, &result);
02527         GAT_TEST( GAT_SUCCESS == retval );
02528         GAT_TEST( GATFalse == result );
02529         retval = GATString_EndsWith(gatTargetString, gatEmptyString, &result);
02530         GAT_TEST( GAT_SUCCESS == retval );
02531         GAT_TEST( GATTrue == result );
02532         retval = GATString_EndsWith(gatEmptyString, gatTargetString, &result);
02533         GAT_TEST( GAT_SUCCESS == retval );
02534         GAT_TEST( GATFalse == result );
02535 
02536         GATString_Destroy( &gatSourceString );
02537         GATString_Destroy( &gatTargetString );
02538       }
02539     }
02540   
02541     GAT_TEST_STOP ();
02542     
02543     /* Close new file */
02544     fclose( newFile );    
02545   }
02546   
02547   /* Close encoding file */
02548   fclose( encodingFile );
02549   
02550   /* Destroy gatEmptyString */
02551   GATString_Destroy( &gatEmptyString );
02552   
02553   return GATTrue;
02554 }
02555 
02556 static GATBool GATString_StartsWith_Test( void )
02557 {
02558   int           retval;
02559   FILE         *newFile;
02560   GATBool       result;
02561 //GATBool       isEqual;
02562   char          encoding[41];
02563   int           lengthInBytes;
02564   FILE         *encodingFile;
02565   char          encodingFileName[256];
02566   char          unicode[256];
02567   const char   *newFileName;
02568   char          newTestName[256];
02569   unsigned char buffer[4];
02570   GATString     gatEmptyString;
02571   GATString     gatSourceString;
02572   GATString     gatTargetString;
02573   unsigned int  i0, i1, i2, i3;
02574   
02575   /* Create emptry GATString */
02576   gatEmptyString = GATString_Create( "", 1, "ASCII" );
02577   GAT_TEST( NULL != gatEmptyString );
02578   
02579   sprintf(encodingFileName, "%s", ENCFILE);
02580 
02581   /* Open encoding file */
02582   encodingFile = fopen( encodingFileName, "r" );
02583   GAT_TEST( NULL != encodingFile );
02584   
02585   /* Get next encoding */
02586   while( NULL != fgets(encoding, 41, encodingFile) )
02587   {
02588     /* remove the trailing '\n' */
02589     char *eol = strchr(encoding, '\n');
02590     
02591     if (NULL != eol)
02592     {
02593       *eol = '\0';
02594     }
02595     
02596     /* Create new file name */
02597     newFileName = GATTest_GetTempFileNameF ("gat_%s_To_UCS_4_INTERNAL", encoding);
02598     GAT_TEST (newFileName);
02599 
02600     sprintf(newTestName, "GATString StartsWith Test: %s to UCS_4_INTERNAL", 
02601             encoding);
02602   
02603     GAT_TEST_START(newTestName);
02604     
02605     /* Open new file */
02606     newFile = fopen( newFileName, "r" );
02607     GAT_TEST( NULL != newFile );
02608     
02609     /* Read in length in bytes */
02610     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
02611     {
02612       if( 1 == lengthInBytes )
02613       {
02614         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &unicode);
02615         GAT_TEST( EOF != retval );
02616         
02617         buffer[0] = i0;
02618         
02619         gatSourceString = GATString_Create( (const char *) buffer, 1, encoding );
02620         GAT_TEST( NULL != gatSourceString);
02621         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02622         GAT_TEST( NULL != gatTargetString);
02623         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02624         GAT_TEST( GAT_SUCCESS == retval );
02625         GAT_TEST( GATTrue == result );
02626         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02627         GAT_TEST( GAT_SUCCESS == retval );
02628         GAT_TEST( GATTrue == result );
02629         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02630         GAT_TEST( GAT_SUCCESS == retval );
02631         GAT_TEST( GATTrue == result );
02632         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02633         GAT_TEST( GAT_SUCCESS == retval );
02634         GAT_TEST( GATFalse == result );
02635         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02636         GAT_TEST( GAT_SUCCESS == retval );
02637         GAT_TEST( GATTrue == result );
02638         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02639         GAT_TEST( GAT_SUCCESS == retval );
02640         GAT_TEST( GATFalse == result );
02641 
02642         GATString_Destroy( &gatSourceString );
02643         GATString_Destroy( &gatTargetString );
02644       }
02645       
02646       if( 2 == lengthInBytes )
02647       {
02648         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &unicode);
02649         GAT_TEST( EOF != retval );
02650         
02651         buffer[0] = i0;
02652         buffer[1] = i1;
02653         
02654         gatSourceString = GATString_Create( (const char *) buffer, 2, encoding );
02655         GAT_TEST( NULL != gatSourceString);
02656         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02657         GAT_TEST( NULL != gatTargetString);
02658         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02659         GAT_TEST( GAT_SUCCESS == retval );
02660         GAT_TEST( GATTrue == result );
02661         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02662         GAT_TEST( GAT_SUCCESS == retval );
02663         GAT_TEST( GATTrue == result );
02664         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02665         GAT_TEST( GAT_SUCCESS == retval );
02666         GAT_TEST( GATTrue == result );
02667         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02668         GAT_TEST( GAT_SUCCESS == retval );
02669         GAT_TEST( GATFalse == result );
02670         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02671         GAT_TEST( GAT_SUCCESS == retval );
02672         GAT_TEST( GATTrue == result );
02673         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02674         GAT_TEST( GAT_SUCCESS == retval );
02675         GAT_TEST( GATFalse == result );
02676 
02677         GATString_Destroy( &gatSourceString );
02678         GATString_Destroy( &gatTargetString );
02679       }
02680       
02681       if( 3 == lengthInBytes )
02682       {
02683         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &unicode);
02684         GAT_TEST( EOF != retval );
02685         
02686         buffer[0] = i0;
02687         buffer[1] = i1;
02688         buffer[2] = i2;
02689         
02690         gatSourceString = GATString_Create( (const char *) buffer, 3, encoding );
02691         GAT_TEST( NULL != gatSourceString);
02692         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02693         GAT_TEST( NULL != gatTargetString);
02694         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02695         GAT_TEST( GAT_SUCCESS == retval );
02696         GAT_TEST( GATTrue == result );
02697         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02698         GAT_TEST( GAT_SUCCESS == retval );
02699         GAT_TEST( GATTrue == result );
02700         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02701         GAT_TEST( GAT_SUCCESS == retval );
02702         GAT_TEST( GATTrue == result );
02703         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02704         GAT_TEST( GAT_SUCCESS == retval );
02705         GAT_TEST( GATFalse == result );
02706         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02707         GAT_TEST( GAT_SUCCESS == retval );
02708         GAT_TEST( GATTrue == result );
02709         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02710         GAT_TEST( GAT_SUCCESS == retval );
02711         GAT_TEST( GATFalse == result );
02712 
02713         GATString_Destroy( &gatSourceString );
02714         GATString_Destroy( &gatTargetString );
02715       }
02716       
02717       if( 4 == lengthInBytes )
02718       {        
02719         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &unicode);
02720         GAT_TEST( EOF != retval );
02721         
02722         buffer[0] = i0;
02723         buffer[1] = i1;
02724         buffer[2] = i2;
02725         buffer[3] = i3;
02726         
02727         gatSourceString = GATString_Create( (const char *) buffer, 4, encoding );
02728         GAT_TEST( NULL != gatSourceString);
02729         gatTargetString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02730         GAT_TEST( NULL != gatTargetString);
02731         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02732         GAT_TEST( GAT_SUCCESS == retval );
02733         GAT_TEST( GATTrue == result );
02734         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02735         GAT_TEST( GAT_SUCCESS == retval );
02736         GAT_TEST( GATTrue == result );
02737         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02738         GAT_TEST( GAT_SUCCESS == retval );
02739         GAT_TEST( GATTrue == result );
02740         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02741         GAT_TEST( GAT_SUCCESS == retval );
02742         GAT_TEST( GATFalse == result );
02743         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02744         GAT_TEST( GAT_SUCCESS == retval );
02745         GAT_TEST( GATTrue == result );
02746         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02747         GAT_TEST( GAT_SUCCESS == retval );
02748         GAT_TEST( GATFalse == result );
02749 
02750         GATString_Destroy( &gatSourceString );
02751         GATString_Destroy( &gatTargetString );
02752       }
02753     }
02754     
02755     /* Close new file */
02756     fclose( newFile );
02757     
02758     /* Create new file name */
02759     newFileName = GATTest_GetTempFileNameF ("gat_UCS_4_INTERNAL_To_%s", encoding);
02760     GAT_TEST (newFileName);
02761     
02762     /* Open new file */
02763     newFile = fopen( newFileName, "r" );
02764     GAT_TEST( NULL != newFile );
02765     
02766     /* Read in length in bytes */
02767     while( EOF != fscanf(newFile, "%d\n", &lengthInBytes) )
02768     {
02769       if( 1 == lengthInBytes )
02770       {
02771         retval = fscanf(newFile, "0x%02X\t%s\n", &i0, &unicode);
02772         GAT_TEST( EOF != retval );
02773         
02774         buffer[0] = i0;
02775         
02776         gatTargetString = GATString_Create( (const char *) buffer, 1, encoding );
02777         GAT_TEST( NULL != gatTargetString);
02778         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02779         GAT_TEST( NULL != gatSourceString);
02780         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02781         GAT_TEST( GAT_SUCCESS == retval );
02782         GAT_TEST( GATTrue == result );
02783         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02784         GAT_TEST( GAT_SUCCESS == retval );
02785         GAT_TEST( GATTrue == result );
02786         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02787         GAT_TEST( GAT_SUCCESS == retval );
02788         GAT_TEST( GATTrue == result );
02789         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02790         GAT_TEST( GAT_SUCCESS == retval );
02791         GAT_TEST( GATFalse == result );
02792         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02793         GAT_TEST( GAT_SUCCESS == retval );
02794         GAT_TEST( GATTrue == result );
02795         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02796         GAT_TEST( GAT_SUCCESS == retval );
02797         GAT_TEST( GATFalse == result );
02798 
02799         GATString_Destroy( &gatSourceString );
02800         GATString_Destroy( &gatTargetString );
02801       }
02802      
02803       if( 2 == lengthInBytes )
02804       {
02805         retval = fscanf(newFile, "0x%02X%02X\t%s\n", &i0, &i1, &unicode);
02806         GAT_TEST( EOF != retval );
02807         
02808         buffer[0] = i0;
02809         buffer[1] = i1;
02810         
02811         gatTargetString = GATString_Create( (const char *) buffer, 2, encoding );
02812         GAT_TEST( NULL != gatTargetString);
02813         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02814         GAT_TEST( NULL != gatSourceString);
02815         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02816         GAT_TEST( GAT_SUCCESS == retval );
02817         GAT_TEST( GATTrue == result );
02818         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02819         GAT_TEST( GAT_SUCCESS == retval );
02820         GAT_TEST( GATTrue == result );
02821         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02822         GAT_TEST( GAT_SUCCESS == retval );
02823         GAT_TEST( GATTrue == result );
02824         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02825         GAT_TEST( GAT_SUCCESS == retval );
02826         GAT_TEST( GATFalse == result );
02827         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02828         GAT_TEST( GAT_SUCCESS == retval );
02829         GAT_TEST( GATTrue == result );
02830         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02831         GAT_TEST( GAT_SUCCESS == retval );
02832         GAT_TEST( GATFalse == result );
02833 
02834         GATString_Destroy( &gatSourceString );
02835         GATString_Destroy( &gatTargetString );
02836       }
02837       
02838       if( 3 == lengthInBytes )
02839       {
02840         retval = fscanf(newFile, "0x%02X%02X%02X\t%s\n", &i0, &i1, &i2, &unicode);
02841         GAT_TEST( EOF != retval );
02842         
02843         buffer[0] = i0;
02844         buffer[1] = i1;
02845         buffer[2] = i2;
02846         
02847         gatTargetString = GATString_Create( (const char *) buffer, 3, encoding );
02848         GAT_TEST( NULL != gatTargetString);
02849         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02850         GAT_TEST( NULL != gatSourceString);
02851         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02852         GAT_TEST( GAT_SUCCESS == retval );
02853         GAT_TEST( GATTrue == result );
02854         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02855         GAT_TEST( GAT_SUCCESS == retval );
02856         GAT_TEST( GATTrue == result );
02857         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02858         GAT_TEST( GAT_SUCCESS == retval );
02859         GAT_TEST( GATTrue == result );
02860         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02861         GAT_TEST( GAT_SUCCESS == retval );
02862         GAT_TEST( GATFalse == result );
02863         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02864         GAT_TEST( GAT_SUCCESS == retval );
02865         GAT_TEST( GATTrue == result );
02866         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02867         GAT_TEST( GAT_SUCCESS == retval );
02868         GAT_TEST( GATFalse == result );
02869 
02870         GATString_Destroy( &gatSourceString );
02871         GATString_Destroy( &gatTargetString );
02872       }
02873       
02874       if( 4 == lengthInBytes )
02875       {        
02876         retval = fscanf(newFile, "0x%02X%02X%02X%02X\t%s\n", &i0, &i1, &i2, &i3, &unicode);
02877         GAT_TEST( EOF != retval );
02878         
02879         buffer[0] = i0;
02880         buffer[1] = i1;
02881         buffer[2] = i2;
02882         buffer[3] = i3;
02883         
02884         gatTargetString = GATString_Create( (const char *) buffer, 4, encoding );
02885         GAT_TEST( NULL != gatTargetString);
02886         gatSourceString = GATString_Create( (const char *) unicode, 4, "UCS-4-INTERNAL" );
02887         GAT_TEST( NULL != gatSourceString);
02888         retval = GATString_StartsWith(gatSourceString, gatTargetString, &result);
02889         GAT_TEST( GAT_SUCCESS == retval );
02890         GAT_TEST( GATTrue == result );
02891         retval = GATString_StartsWith(gatTargetString, gatSourceString, &result);
02892         GAT_TEST( GAT_SUCCESS == retval );
02893         GAT_TEST( GATTrue == result );
02894         retval = GATString_StartsWith(gatSourceString, gatEmptyString, &result);
02895         GAT_TEST( GAT_SUCCESS == retval );
02896         GAT_TEST( GATTrue == result );
02897         retval = GATString_StartsWith(gatEmptyString, gatSourceString, &result);
02898         GAT_TEST( GAT_SUCCESS == retval );
02899         GAT_TEST( GATFalse == result );
02900         retval = GATString_StartsWith(gatTargetString, gatEmptyString, &result);
02901         GAT_TEST( GAT_SUCCESS == retval );
02902         GAT_TEST( GATTrue == result );
02903         retval = GATString_StartsWith(gatEmptyString, gatTargetString, &result);
02904         GAT_TEST( GAT_SUCCESS == retval );
02905         GAT_TEST( GATFalse == result );
02906 
02907         GATString_Destroy( &gatSourceString );
02908         GATString_Destroy( &gatTargetString );
02909       }
02910     }
02911   
02912     GAT_TEST_STOP ();
02913     
02914     /* Close new file */
02915     fclose( newFile );    
02916   }
02917   
02918   /* Close encoding file */
02919   fclose( encodingFile );
02920   
02921   /* Destroy gatEmptyString */
02922   GATString_Destroy( &gatEmptyString );
02923 
02924   return GATTrue;
02925 }
02926 
02927 static GATBool GATString_Concatenate_Test( void )
02928 {
02929   int retval;
02930   GATBool isEqual;
02931   char encoding[41];
02932   FILE *encodingFile;
02933   char  encodingFileName[256];
02934   GATString emptyString;
02935   GATString helloGATString;
02936   GATString worldGATString;
02937   GATString helloWorldGATString;
02938   GATString encodedHelloGATString;
02939   GATString encodedWorldGATString;
02940   GATString concatinatedGATString1;
02941   GATString concatinatedGATString2;
02942   GATString concatinatedGATString3;
02943   GATString concatinatedGATString4;
02944   GATString concatinatedGATString5;
02945   GATString concatinatedGATString6;
02946   GATString concatinatedGATString7;
02947   GATString concatinatedGATString8;
02948   
02949   GAT_TEST_START("GATString Concatenate Test");
02950 
02951   /* Create reference strings */
02952   emptyString = GATString_Create( "", 1, "ASCII" );
02953   GAT_TEST( NULL != emptyString );
02954   helloGATString = GATString_Create( "Hello ", 7, "ASCII" );
02955   GAT_TEST( NULL != helloGATString );
02956   worldGATString = GATString_Create( "world!", 7, "ASCII" );
02957   GAT_TEST( NULL != worldGATString );
02958   helloWorldGATString = GATString_Create( "Hello world!", 13, "ASCII" );
02959   GAT_TEST( NULL != helloWorldGATString );
02960   
02961   sprintf(encodingFileName, "%s", ENCFILE);
02962 
02963   /* Open encoding file */
02964   encodingFile = fopen( encodingFileName, "r" );
02965   GAT_TEST( NULL != encodingFile );
02966   
02967   /* Get next encoding */
02968   while( NULL != fgets(encoding, 41, encodingFile) )
02969   {
02970     /* remove the trailing '\n' */
02971     char *eol = strchr(encoding, '\n');
02972     
02973     if (NULL != eol)
02974     {
02975       *eol = '\0';
02976     }
02977     
02978     /* Create strings encoded in encoding */
02979     retval = GATString_Translate( helloGATString, encoding, &encodedHelloGATString );
02980     GAT_TEST( GAT_SUCCESS == retval );
02981     retval = GATString_Translate( worldGATString, encoding, &encodedWorldGATString );
02982     GAT_TEST( GAT_SUCCESS == retval );
02983     
02984     /* Concatenate strings */
02985     retval = GATString_Concatenate( helloGATString, worldGATString, &concatinatedGATString1 );
02986     GAT_TEST( GAT_SUCCESS == retval );
02987     retval = GATString_Concatenate( helloGATString, encodedWorldGATString, &concatinatedGATString2 );
02988     GAT_TEST( GAT_SUCCESS == retval );
02989     retval = GATString_Concatenate( encodedHelloGATString, worldGATString, &concatinatedGATString3 );
02990     GAT_TEST( GAT_SUCCESS == retval );
02991     retval = GATString_Concatenate( encodedHelloGATString, encodedWorldGATString, &concatinatedGATString4 );
02992     GAT_TEST( GAT_SUCCESS == retval );
02993     retval = GATString_Concatenate( helloGATString, emptyString, &concatinatedGATString5 );
02994     GAT_TEST( GAT_SUCCESS == retval );
02995     retval = GATString_Concatenate( emptyString, helloGATString, &concatinatedGATString6 );
02996     GAT_TEST( GAT_SUCCESS == retval );
02997     retval = GATString_Concatenate( encodedHelloGATString, emptyString, &concatinatedGATString7 );
02998     GAT_TEST( GAT_SUCCESS == retval );
02999     retval = GATString_Concatenate( emptyString, encodedHelloGATString, &concatinatedGATString8 );
03000     GAT_TEST( GAT_SUCCESS == retval );
03001     
03002     /* Compare strings */
03003     retval = GATString_Equals( helloWorldGATString, concatinatedGATString1, &isEqual );
03004     GAT_TEST( GAT_SUCCESS == retval );
03005     GAT_TEST( GATTrue == isEqual );
03006     retval = GATString_Equals( helloWorldGATString, concatinatedGATString2, &isEqual );
03007     GAT_TEST( GAT_SUCCESS == retval );
03008     GAT_TEST( GATTrue == isEqual );
03009     retval = GATString_Equals( helloWorldGATString, concatinatedGATString3, &isEqual );
03010     GAT_TEST( GAT_SUCCESS == retval );
03011     GAT_TEST( GATTrue == isEqual );
03012     retval = GATString_Equals( helloWorldGATString, concatinatedGATString4, &isEqual );
03013     GAT_TEST( GAT_SUCCESS == retval );
03014     GAT_TEST( GATTrue == isEqual );
03015     retval = GATString_Equals( helloGATString, concatinatedGATString5, &isEqual );
03016     GAT_TEST( GAT_SUCCESS == retval );
03017     GAT_TEST( GATTrue == isEqual );
03018     retval = GATString_Equals( helloGATString, concatinatedGATString6, &isEqual );
03019     GAT_TEST( GAT_SUCCESS == retval );
03020     GAT_TEST( GATTrue == isEqual );
03021     retval = GATString_Equals( helloGATString, concatinatedGATString7, &isEqual );
03022     GAT_TEST( GAT_SUCCESS == retval );
03023     GAT_TEST( GATTrue == isEqual );
03024     retval = GATString_Equals( helloGATString, concatinatedGATString8, &isEqual );
03025     GAT_TEST( GAT_SUCCESS == retval );
03026     GAT_TEST( GATTrue == isEqual );
03027     
03028     /* Destroy encoded strings */
03029     GATString_Destroy( &encodedHelloGATString );
03030     GATString_Destroy( &encodedWorldGATString );
03031     GATString_Destroy( &concatinatedGATString1 );
03032     GATString_Destroy( &concatinatedGATString2 );
03033     GATString_Destroy( &concatinatedGATString3 );
03034     GATString_Destroy( &concatinatedGATString4 );
03035     GATString_Destroy( &concatinatedGATString5 );
03036     GATString_Destroy( &concatinatedGATString6 );
03037     GATString_Destroy( &concatinatedGATString7 );
03038     GATString_Destroy( &concatinatedGATString8 );
03039   }
03040   
03041   /* Close encoding file */
03042   fclose( encodingFile );
03043   
03044   /* Destroy reference strings */
03045   GATString_Destroy( &emptyString );
03046   GATString_Destroy( &helloGATString );
03047   GATString_Destroy( &worldGATString );
03048   GATString_Destroy( &helloWorldGATString );
03049   
03050 
03051   GAT_TEST_STOP ();
03052   return GATTrue;
03053 }
03054 
03055 static GATBool GATString_LastIndexOf_Test( void )
03056 {
03057   int retval;
03058   char encoding[41];
03059   FILE *encodingFile;
03060   char  encodingFileName[256];
03061   GATuint32 queryIndex;
03062   GATString dummyString;
03063   GATString helloGATString;
03064   GATString worldGATString;
03065   GATString helloWorldGATString;
03066   GATString encodedHelloGATString;
03067   GATString encodedWorldGATString;
03068   GATString encodedHelloWorldGATString;
03069   
03070   GAT_TEST_START("GATString LastIndexOf Test");
03071 
03072   /* Create reference strings */
03073   dummyString = GATString_Create( "dummy", 6, "ASCII" );
03074   GAT_TEST( NULL != dummyString );
03075   helloGATString = GATString_Create( "Hello ", 7, "ASCII" );
03076   GAT_TEST( NULL != helloGATString );
03077   worldGATString = GATString_Create( "world!", 7, "ASCII" );
03078   GAT_TEST( NULL != worldGATString );
03079   helloWorldGATString = GATString_Create( "Hello world!", 13, "ASCII" );
03080   GAT_TEST( NULL != helloWorldGATString );
03081   
03082   sprintf(encodingFileName, "%s", ENCFILE);
03083 
03084   /* Open encoding file */
03085   encodingFile = fopen( encodingFileName, "r" );
03086   GAT_TEST( NULL != encodingFile );
03087   
03088   /* Get next encoding */
03089   while( NULL != fgets(encoding, 41, encodingFile) )
03090   {
03091     /* remove the trailing '\n' */
03092     char *eol = strchr(encoding, '\n');
03093     
03094     if (NULL != eol)
03095     {
03096       *eol = '\0';
03097     }
03098     
03099     /* Create strings encoded in encoding */
03100     retval = GATString_Translate( helloGATString, encoding, &encodedHelloGATString );
03101     GAT_TEST( GAT_SUCCESS == retval );
03102     retval = GATString_Translate( worldGATString, encoding, &encodedWorldGATString );
03103     GAT_TEST( GAT_SUCCESS == retval );
03104     retval = GATString_Translate( helloWorldGATString, encoding, &encodedHelloWorldGATString );
03105     GAT_TEST( GAT_SUCCESS == retval );
03106     
03107     /* Get index */
03108     retval = GATString_LastIndexOf( helloWorldGATString, helloGATString, &queryIndex );
03109     GAT_TEST( GAT_SUCCESS == retval );
03110     GAT_TEST( 0 == queryIndex );
03111     retval = GATString_LastIndexOf( encodedHelloWorldGATString, helloGATString, &queryIndex );
03112     GAT_TEST( GAT_SUCCESS == retval );
03113     GAT_TEST( 0 == queryIndex );
03114     retval = GATString_LastIndexOf( helloWorldGATString, encodedHelloGATString, &queryIndex );
03115     GAT_TEST( GAT_SUCCESS == retval );
03116     GAT_TEST( 0 == queryIndex );
03117     retval = GATString_LastIndexOf( encodedHelloWorldGATString, encodedHelloGATString, &queryIndex );
03118     GAT_TEST( GAT_SUCCESS == retval );
03119     GAT_TEST( 0 == queryIndex );
03120     
03121     retval = GATString_LastIndexOf( helloWorldGATString, worldGATString, &queryIndex );
03122     GAT_TEST( GAT_SUCCESS == retval );
03123     GAT_TEST( 6 == queryIndex );
03124     retval = GATString_LastIndexOf( encodedHelloWorldGATString, worldGATString, &queryIndex );
03125     GAT_TEST( GAT_SUCCESS == retval );
03126     GAT_TEST( 6 == queryIndex );
03127     retval = GATString_LastIndexOf( helloWorldGATString, encodedWorldGATString, &queryIndex );
03128     GAT_TEST( GAT_SUCCESS == retval );
03129     GAT_TEST( 6 == queryIndex );
03130     retval = GATString_LastIndexOf( encodedHelloWorldGATString, encodedWorldGATString, &queryIndex );
03131     GAT_TEST( GAT_SUCCESS == retval );
03132     GAT_TEST( 6 == queryIndex );
03133     
03134     retval = GATString_LastIndexOf( helloWorldGATString, dummyString, &queryIndex );
03135     GAT_TEST( GAT_SUCCESS == retval );
03136     GAT_TEST( (GATuint32)(-1) == queryIndex );
03137     retval = GATString_LastIndexOf( encodedHelloWorldGATString, dummyString, &queryIndex );
03138     GAT_TEST( GAT_SUCCESS == retval );
03139     GAT_TEST( (GATuint32)(-1) == queryIndex );
03140     
03141     /* Destroy encoded strings */
03142     GATString_Destroy( &encodedHelloGATString );
03143     GATString_Destroy( &encodedWorldGATString );
03144     GATString_Destroy( &encodedHelloWorldGATString );
03145   }
03146   
03147   /* Close encoding file */
03148   fclose( encodingFile );
03149   
03150   /* Destroy reference strings */
03151   GATString_Destroy( &dummyString );
03152   GATString_Destroy( &helloGATString );
03153   GATString_Destroy( &worldGATString );
03154   GATString_Destroy( &helloWorldGATString );
03155   
03156 
03157   GAT_TEST_STOP ();
03158   return GATTrue;
03159 }
03160 
03161 static GATBool GATString_FirstIndexOf_Test( void )
03162 {
03163   int retval;
03164   char encoding[41];
03165   FILE *encodingFile;
03166   char  encodingFileName[256];
03167   GATuint32 queryIndex;
03168   GATString dummyString;
03169   GATString helloGATString;
03170   GATString worldGATString;
03171   GATString helloWorldGATString;
03172   GATString encodedHelloGATString;
03173   GATString encodedWorldGATString;
03174   GATString encodedHelloWorldGATString;
03175   
03176   GAT_TEST_START("GATString FirstIndexOf Test");
03177 
03178   /* Create reference strings */
03179   dummyString = GATString_Create( "dummy", 6, "ASCII" );
03180   GAT_TEST( NULL != dummyString );
03181   helloGATString = GATString_Create( "Hello ", 7, "ASCII" );
03182   GAT_TEST( NULL != helloGATString );
03183   worldGATString = GATString_Create( "world!", 7, "ASCII" );
03184   GAT_TEST( NULL != worldGATString );
03185   helloWorldGATString = GATString_Create( "Hello world!", 13, "ASCII" );
03186   GAT_TEST( NULL != helloWorldGATString );
03187   
03188   sprintf(encodingFileName, "%s", ENCFILE);
03189 
03190   /* Open encoding file */
03191   encodingFile = fopen( encodingFileName, "r" );
03192   GAT_TEST( NULL != encodingFile );
03193   
03194   /* Get next encoding */
03195   while( NULL != fgets(encoding, 41, encodingFile) )
03196   {
03197     /* remove the trailing '\n' */
03198     char *eol = strchr(encoding, '\n');
03199     
03200     if (NULL != eol)
03201     {
03202       *eol = '\0';
03203     }
03204     
03205     /* Create strings encoded in encoding */
03206     retval = GATString_Translate( helloGATString, encoding, &encodedHelloGATString );
03207     GAT_TEST( GAT_SUCCESS == retval );
03208     retval = GATString_Translate( worldGATString, encoding, &encodedWorldGATString );
03209     GAT_TEST( GAT_SUCCESS == retval );
03210     retval = GATString_Translate( helloWorldGATString, encoding, &encodedHelloWorldGATString );
03211     GAT_TEST( GAT_SUCCESS == retval );
03212     
03213     /* Get index */
03214     retval = GATString_FirstIndexOf( helloWorldGATString, helloGATString, &queryIndex );
03215     GAT_TEST( GAT_SUCCESS == retval );
03216     GAT_TEST( 0 == queryIndex );
03217     retval = GATString_FirstIndexOf( encodedHelloWorldGATString, helloGATString, &queryIndex );
03218     GAT_TEST( GAT_SUCCESS == retval );
03219     GAT_TEST( 0 == queryIndex );
03220     retval = GATString_FirstIndexOf( helloWorldGATString, encodedHelloGATString, &queryIndex );
03221     GAT_TEST( GAT_SUCCESS == retval );
03222     GAT_TEST( 0 == queryIndex );
03223     retval = GATString_FirstIndexOf( encodedHelloWorldGATString, encodedHelloGATString, &queryIndex );
03224     GAT_TEST( GAT_SUCCESS == retval );
03225     GAT_TEST( 0 == queryIndex );
03226     
03227     retval = GATString_FirstIndexOf( helloWorldGATString, worldGATString, &queryIndex );
03228     GAT_TEST( GAT_SUCCESS == retval );
03229     GAT_TEST( 6 == queryIndex );
03230     retval = GATString_FirstIndexOf( encodedHelloWorldGATString, worldGATString, &queryIndex );
03231     GAT_TEST( GAT_SUCCESS == retval );
03232     GAT_TEST( 6 == queryIndex );
03233     retval = GATString_FirstIndexOf( helloWorldGATString, encodedWorldGATString, &queryIndex );
03234     GAT_TEST( GAT_SUCCESS == retval );
03235     GAT_TEST( 6 == queryIndex );
03236     retval = GATString_FirstIndexOf( encodedHelloWorldGATString, encodedWorldGATString, &queryIndex );
03237     GAT_TEST( GAT_SUCCESS == retval );
03238     GAT_TEST( 6 == queryIndex );
03239     
03240     retval = GATString_FirstIndexOf( helloWorldGATString, dummyString, &queryIndex );
03241     GAT_TEST( GAT_SUCCESS == retval );
03242     GAT_TEST( (GATuint32)(-1) == queryIndex );
03243     retval = GATString_FirstIndexOf( encodedHelloWorldGATString, dummyString, &queryIndex );
03244     GAT_TEST( GAT_SUCCESS == retval );
03245     GAT_TEST( (GATuint32)(-1) == queryIndex );
03246     
03247     /* Destroy encoded strings */
03248     GATString_Destroy( &encodedHelloGATString );
03249     GATString_Destroy( &encodedWorldGATString );
03250     GATString_Destroy( &encodedHelloWorldGATString );
03251   }
03252   
03253   /* Close encoding file */
03254   fclose( encodingFile );
03255   
03256   /* Destroy reference strings */
03257   GATString_Destroy( &dummyString );
03258   GATString_Destroy( &helloGATString );
03259   GATString_Destroy( &worldGATString );
03260   GATString_Destroy( &helloWorldGATString );
03261   
03262 
03263   GAT_TEST_STOP ();
03264   return GATTrue;
03265 }
03266 
03267 static GATBool GATString_GetSubString_Test( void )
03268 {
03269   int retval;
03270   GATBool isEqual;
03271   char encoding[41];
03272   FILE *encodingFile;
03273   char  encodingFileName[256];
03274   GATString helloGATString;
03275   GATString worldGATString;
03276   GATString subStringGATString;
03277   GATString helloWorldGATString;
03278   GATString encodedHelloWorldGATString;
03279   
03280   GAT_TEST_START("GATString GetSubString Test");
03281 
03282   /* Create reference strings */
03283   helloGATString = GATString_Create( "Hello ", 6, "ASCII" );
03284   GAT_TEST( NULL != helloGATString );
03285   worldGATString = GATString_Create( "world!", 6, "ASCII" );
03286   GAT_TEST( NULL != worldGATString );
03287   helloWorldGATString = GATString_Create( "Hello world!", 12, "ASCII" );
03288   GAT_TEST( NULL != helloWorldGATString );
03289   
03290   sprintf(encodingFileName, "%s", ENCFILE);
03291 
03292   /* Open encoding file */
03293   encodingFile = fopen( encodingFileName, "r" );
03294   GAT_TEST( NULL != encodingFile );
03295   
03296   /* Get next encoding */
03297   while( NULL != fgets(encoding, 41, encodingFile) )
03298   {
03299     /* remove the trailing '\n' */
03300     char *eol = strchr(encoding, '\n');
03301     
03302     if (NULL != eol)
03303     {
03304       *eol = '\0';
03305     }
03306     
03307     /* Create strings encoded in encoding */
03308     retval = GATString_Translate( helloWorldGATString, encoding, &encodedHelloWorldGATString );
03309     GAT_TEST( GAT_SUCCESS == retval );
03310     
03311     /* Get sub-strings */
03312     retval = GATString_GetSubString( encodedHelloWorldGATString, 0, 12, &subStringGATString );
03313     GAT_TEST( GAT_SUCCESS == retval );
03314     retval = GATString_Equals( helloWorldGATString, subStringGATString, &isEqual );
03315     GAT_TEST( GAT_SUCCESS == retval );
03316     GAT_TEST( GATTrue == isEqual );
03317     GATString_Destroy( &subStringGATString );
03318     
03319     retval = GATString_GetSubString( encodedHelloWorldGATString, 0, 6, &subStringGATString );
03320     GAT_TEST( GAT_SUCCESS == retval );
03321     retval = GATString_Equals( helloGATString, subStringGATString, &isEqual );
03322     GAT_TEST( GAT_SUCCESS == retval );
03323     GAT_TEST( GATTrue == isEqual );
03324     GATString_Destroy( &subStringGATString );
03325     
03326     retval = GATString_GetSubString( encodedHelloWorldGATString, 6, 12, &subStringGATString );
03327     GAT_TEST( GAT_SUCCESS == retval );
03328     retval = GATString_Equals( worldGATString, subStringGATString, &isEqual );
03329     GAT_TEST( GAT_SUCCESS == retval );
03330     GAT_TEST( GATTrue == isEqual );
03331     GATString_Destroy( &subStringGATString );
03332     
03333     /* Destroy strings */
03334     GATString_Destroy( &encodedHelloWorldGATString );
03335   }
03336   
03337   /* Close encoding file */
03338   fclose( encodingFile );
03339   
03340   /* Destroy reference strings */
03341   GATString_Destroy( &helloGATString );
03342   GATString_Destroy( &worldGATString );
03343   GATString_Destroy( &helloWorldGATString );
03344   
03345 
03346   GAT_TEST_STOP ();
03347   return GATTrue;
03348 }
03349 
03350 static GATBool GATString_GetInterface_Test( void )
03351 {
03352   int retval;
03353   void *interface_ptr;
03354   GATString emptyString;
03355   
03356   GAT_TEST_START("GATString GetInterface Test");
03357 
03358   /* Create empty string */
03359   emptyString = GATString_Create( "", 1, "ASCII" );
03360   GAT_TEST( NULL != emptyString );
03361   
03362   retval = GATString_GetInterface(emptyString, GATInterface_ISerialisable, &interface_ptr);
03363   GAT_TEST( GAT_SUCCESS == retval );
03364   GAT_TEST( NULL != interface_ptr );  
03365   retval = GATString_GetInterface(emptyString, GATInterface_IAdvertisable, &interface_ptr);
03366   GAT_TEST( GAT_SUCCESS == retval );
03367   GAT_TEST( NULL != interface_ptr );
03368   retval = GATString_GetInterface(emptyString, GATInterface_IResource, &interface_ptr);
03369   GAT_TEST( GAT_NO_INTERFACE == retval );
03370   
03371   /* Destroy empty string */
03372   GATString_Destroy( &emptyString );
03373   
03374 
03375   GAT_TEST_STOP ();
03376   return GATTrue;
03377 }
03378