home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / test / cintltst / cformtst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  3.0 KB  |  106 lines

  1. /*
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1996                                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1999                    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.                  *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure             *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                              *
  10. *                                                                                       *
  11. *****************************************************************************************
  12. ********************************************************************************
  13. *
  14. * File CFORMTST.C
  15. *
  16. * Modification History:
  17. *        Name                     Description            
  18. *     Madhu Katragadda               Creation
  19. *********************************************************************************
  20. */
  21.  
  22. /* FormatTest is a medium top level test for everything in the  C FORMAT API */
  23.  
  24. #include "cintltst.h"
  25. #include "cformtst.h"
  26.  
  27. void addCalTest(TestNode**);
  28. void addDateForTest(TestNode**);
  29. void addNumForTest(TestNode**);
  30. void addMsgForTest(TestNode**);
  31. void addDateForRgrTest(TestNode**);
  32. void addNumFrDepTest(TestNode**);
  33. void addDtFrDepTest(TestNode**);
  34.  
  35.  
  36. void checkHeap()
  37. {
  38.   int i;
  39.   void *n[2048];
  40.  
  41.   log_info("checkHeap...");
  42.  
  43.   
  44.   for(i=0;i<1;i++)
  45.     {
  46.             n[i]= malloc(i+15); 
  47.     }
  48.   
  49.   /*  for(i=0;i<2048;i++)
  50.     {
  51.       free(n[i]);
  52.       }*/
  53. }
  54.  
  55. void addFormatTest(TestNode** root)
  56. {
  57.     addCalTest(root);
  58.  
  59.     /*    addTest(root, &checkHeap, "/tsformat/mallocTest2" ); */
  60.  
  61.     addDateForTest(root);
  62.  
  63.     /*    addTest(root, &checkHeap, "/tsformat/mallocTest3" ); */
  64.  
  65.     addNumForTest(root);
  66.  
  67.     /*    addTest(root, &checkHeap, "/tsformat/mallocTest4" );  */
  68.  
  69.     addNumFrDepTest(root);
  70.  
  71.     /* addTest(root, &checkHeap, "/tsformat/mallocTest5" );  */
  72.  
  73.     addMsgForTest(root);
  74.     addDateForRgrTest(root);
  75.     addDtFrDepTest(root);
  76.     
  77.     
  78. }
  79. /*INternal functions used*/
  80.  
  81. UChar* myDateFormat(UDateFormat* dat, UDate d1)
  82. {
  83.     UChar *result1;
  84.     int32_t resultlength, resultlengthneeded;
  85.     UFieldPosition pos;
  86.     UErrorCode status = U_ZERO_ERROR;
  87.     
  88.  
  89.     resultlength=0;
  90.     resultlengthneeded=udat_format(dat, d1, NULL, resultlength, &pos, &status);
  91.     if(status==U_BUFFER_OVERFLOW_ERROR)
  92.     {
  93.         status=U_ZERO_ERROR;
  94.         resultlength=resultlengthneeded+1;
  95.         result1=(UChar*)malloc(sizeof(UChar) * resultlength);
  96.         udat_format(dat, d1, result1, resultlength, &pos, &status);
  97.     }
  98.     if(U_FAILURE(status))
  99.     {
  100.         log_err("Error in formatting using udat_format(.....): %s\n", myErrorName(status));
  101.         return 0;
  102.     }
  103.     return result1;
  104.  
  105. }
  106.