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

  1.  
  2. /* t4open
  3.  
  4.    (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
  5.  
  6.    Tests Code Base by repeatedly opening and closing files.
  7. */
  8.  
  9. #include "p4misc.h"
  10. #include "d4all.h"
  11. #include "w4.h"
  12. #include "u4error.h"
  13.  
  14. #include <string.h>
  15. #include <stdlib.h>
  16.  
  17. static  void  er(void) ;
  18.  
  19. static  void er() 
  20. {
  21.    u4error( 0, "t4open:  Error", (char *) 0 ) ;
  22.    w4exit(0) ;
  23. }
  24.  
  25. static FIELD testfields[] =
  26. {
  27.    /* Name  ,  Type,  Width,  Dec,  Offset */
  28.    {"N1        ",   'F',      5,    2,    0    },
  29.    {"N2        ",   'N',     10,    0,    0    },
  30.    {"C1        ",   'C',     10,    0,    0    },
  31.    {"C2        ",   'C',     10,    0,    0    },
  32.    {"C3        ",   'C',     10,    0,    0    },
  33.    {"C4        ",   'C',     15,    0,    0    },
  34.    {"C5        ",   'C',     15,    0,    0    },
  35.    {"D1        ",   'D',      8,    0,    0    },
  36.    {"D2        ",   'D',      8,    0,    0    },
  37.    {"L1        ",   'L',      1,    0,    0    },
  38.    {"L2        ",   'L',      1,    0,    0    }
  39. };
  40.  
  41.  
  42. main( int argc, char **argv )
  43. {
  44.    long  num_times, i_time ;
  45.    int  c;
  46.  
  47.    if ( argc < 2 )
  48.       num_times =  20L ;
  49.    else
  50.    {
  51.       num_times =  atol( argv[1] ) ;
  52.       if ( num_times <= 0L )  num_times =  20L ;
  53.    }
  54.  
  55.    #ifdef NO_HUGE
  56.       #ifdef IS_386
  57.          d4init() ;
  58.       #else
  59.          d4initialize( 4, 4, 20, 1000, 20000L ) ;
  60.       #endif
  61.    #else
  62.       d4init() ;
  63.    #endif
  64.    w4clear(-1) ;
  65.  
  66.    if ( d4create("t4open",  11,testfields,0) < 0 )  er() ;
  67.    if ( i4index( "t4open1", "N1", 0, 0 ) < 0 )  er() ;
  68.    if ( i4index( "t4open2", "C1", 0, 0 ) < 0 )  er() ;
  69.    if ( d4create("t4open2", 11,testfields,0) < 0 )  er() ;
  70.    if ( i4index( "t4open3", "C5", 0, 0 ) < 0 )  er() ;
  71.    if ( i4index( "t4open4", "D2", 0, 0 ) < 0 )  er() ;
  72.    d4close_all();
  73.  
  74.    w4( 0,0, "Num Open/Close:" ) ;
  75.    w4long( w4row(),w4col(), num_times, 6 ) ;
  76.    c =  w4col() ;
  77.  
  78.    for ( i_time = 1L; i_time <= num_times; i_time++ )
  79.    {
  80.       w4long( w4row(),c, i_time, 6 ) ;
  81.  
  82.       if ( d4use(  "t4open"  ) < 0 ) er() ;
  83.       if ( i4open( "t4open1" ) < 0 ) er() ;
  84.       if ( i4open( "t4open2" ) < 0 ) er() ;
  85.       if ( d4use(  "t4open2" ) < 0 ) er() ;
  86.       if ( i4open( "t4open3" ) < 0 ) er() ;
  87.       if ( i4open( "t4open4" ) < 0 ) er() ;
  88.  
  89.       if ( d4close_all() < 0 ) er() ;
  90.    }
  91.  
  92.  
  93.    #ifdef H4TEST
  94.    {
  95.       int  rc ;
  96.       d4init_undo() ;
  97.       rc = h4free_check(32000) ;
  98.       d4init() ;
  99.       if ( rc != 0 )
  100.       {
  101.          u4error( 0, "t4open:  Memory items not freed", (char *) 0 );
  102.          w4exit(1) ;
  103.       }
  104.    }
  105.    #endif
  106.  
  107.    w4handle(1) ;
  108.    w4( w4row()+1,0, "t4open:  SUCCESS" ) ;
  109.    w4exit(0) ;
  110. }
  111.  
  112.