home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / TEST / T4DATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  2.2 KB  |  107 lines

  1.  
  2. /* t4date.c
  3.  
  4.    (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
  5.  
  6.    Tests Code Base date conversion routines.
  7. */
  8.  
  9. #include "p4misc.h"
  10. #include "d4all.h"
  11. #include "w4.h"
  12. #include "u4error.h"
  13.  
  14. #include <string.h>
  15.  
  16. #ifndef UNIX
  17. #include <conio.h>
  18. #endif
  19.  
  20. main()
  21. {
  22.    double total_date, index_date, index_test_date;
  23.    char   dbf_date[10];
  24.    int    c ;
  25.  
  26.    #ifdef NO_HUGE
  27.       #ifdef IS_386
  28.          d4init() ;
  29.       #else
  30.          d4initialize( 4, 4, 20, 1000, 20000L ) ;
  31.       #endif
  32.    #else
  33.       d4init() ;
  34.    #endif
  35.    w4clear(-1) ;
  36.  
  37.    memset( dbf_date, 0, (size_t) sizeof(dbf_date) ) ;
  38.  
  39.    index_date = 2444606.0 ;
  40.    c4dt_str( dbf_date, &index_date );
  41.  
  42.    if ( strcmp( dbf_date, "19810101") != 0 )
  43.    {
  44.       u4error( 0, "\nDate Conversion Error on 19810101", (char *) 0 ) ;
  45.       w4exit(1) ;
  46.    }
  47.  
  48.    total_date = 366L*400L+index_date;
  49.  
  50.    w4( 0,0, "Testing Date: " ) ;
  51.    c =  w4col() ;
  52.  
  53.    for ( ; index_date <= total_date; index_date++)
  54.    {
  55.       #ifndef UNIX
  56.          if ( kbhit() )
  57.          {
  58.             int rc ;
  59.  
  60.             g4char() ;  /* Use up the character. */
  61.             rc = w4display( "Do you wish to stop the Date Test (Y/N) ?", (char *) 0 ) ;
  62.  
  63.             if ( rc == (int) 'Y' || rc == (int) 'y' )
  64.             {
  65.                w4( w4row()+1,0, "Aborting Date Test on User Request." ) ;
  66.                w4exit(0) ;
  67.             }
  68.          }
  69.       #endif
  70.       w4( w4row(),c, dbf_date ) ;
  71.  
  72.       memset( dbf_date, 0, (size_t) sizeof(dbf_date) ) ;
  73.       c4dt_str( dbf_date, &index_date );
  74.       if ( c4dt_julian( dbf_date, &index_test_date ) != 0 )
  75.       {
  76.          u4error( 0, "t4date:  c4dt_julian", (char *) 0 ) ;
  77.          w4exit(1) ;
  78.       }
  79.  
  80.       if (index_date != index_test_date ) 
  81.       {
  82.          u4error( 0, "t4date:  c4dt_julian", (char *) 0 ) ;
  83.          w4exit(1) ;
  84.       }
  85.  
  86.    }
  87.  
  88.  
  89.    #ifdef H4TEST
  90.    {
  91.       int  rc ;
  92.       d4init_undo() ;
  93.       rc = h4free_check(32000) ;
  94.       d4init() ;
  95.       if ( rc != 0 )
  96.       {
  97.          u4error( 0, "t4date:  Memory items not freed", (char *) 0 );
  98.          w4exit(1) ;
  99.       }
  100.    }
  101.    #endif
  102.  
  103.    w4handle(1) ;
  104.    w4( w4row()+1,0, "t4date:  SUCCESS" ) ;
  105.    w4exit(0) ;
  106. }
  107.