home *** CD-ROM | disk | FTP | other *** search
-
- /* t4large.c
-
- (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- Tests Creating a large database.
- */
-
- #include "p4misc.h"
- #include "d4all.h"
- #include "w4.h"
- #include "u4error.h"
-
- #include <string.h>
-
- FIELD fields[] =
- {
- { "C", 'C', 25, 0, 0 },
- { "N", 'N', 5, 0, 0 },
- } ;
-
- static long middle_rec = 0x10010L ;
- static long end_rec = 0x10200L ;
-
-
- static int add(long,long,long,int) ;
-
- static int add( long f_ref, long start_rec, long end_rec, int c )
- {
- long i_rec ;
-
- for ( i_rec = start_rec; i_rec <= end_rec; i_rec++)
- {
- char buf[80] ;
-
- w4long( w4row(),c, i_rec, 6 ) ;
-
- c4ltoa( i_rec, buf, f4width(f_ref) ) ;
- f4replace( f_ref, buf ) ;
- if ( d4write( 0L ) != 0 )
- {
- u4error( 0, "t4large: d4write", (char *) 0 ) ;
- w4exit(1) ;
- }
- }
-
- return 0 ;
- }
-
-
- main()
- {
- int i_ref, c ;
- long i_rec, f_ref ;
-
- #ifdef NO_HUGE
- #ifdef IS_386
- d4init() ;
- #else
- d4initialize( 4, 4, 20, 1000, 20000L ) ;
- #endif
- #else
- d4init() ;
- #endif
- w4clear(-1) ;
-
- if ( d4create( "t4large", 2, fields, 0 ) != 0 )
- {
- u4error( 0, "t4large: d4create", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- f_ref = f4ref( "C" ) ;
-
- w4(0,0, "Adding Record:" ) ;
- c = w4col() ;
-
- /* Add most without an index file so that the test does not take too long. */
- add( f_ref, 1L, middle_rec, c ) ;
-
- w4(w4row()+1,0, "Indexing Database" ) ;
- i_ref = i4index( "t4large", "C", 0, 0 ) ;
-
- w4(w4row()+1,0, "Adding Record:" ) ;
- add( f_ref, middle_rec+1, end_rec, c ) ; /* Add the rest with an index file. */
-
- if ( i4check(i_ref) != 0 )
- {
- u4error( 0, "t4large: i4check", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- d4bottom() ;
-
- for ( i_rec = end_rec; i_rec >= 1L; i_rec-- )
- {
- char buf[80] ;
-
- c4ltoa( i_rec, buf, f4width(f_ref) ) ;
- if ( memcmp( buf, f4ptr(f_ref), f4width(f_ref)) != 0 )
- {
- u4error( 0, "t4large: i4check", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- d4skip(-1L) ;
- }
-
- d4close_all() ;
-
-
- #ifdef H4TEST
- {
- int rc ;
- d4init_undo() ;
- rc = h4free_check(32000) ;
- d4init() ;
- if ( rc != 0 )
- {
- u4error( 0, "t4large: Memory items not freed", (char *) 0 );
- w4exit(1) ;
- }
- }
- #endif
-
- w4handle(1) ;
- w4( w4row()+1,0, "t4large: SUCCESS" ) ;
- w4exit(0) ;
- }
-