Changeset 308
- Timestamp:
- 08/21/09 23:02:16 (1 year ago)
- Files:
-
- branches/stdio_rewrite/functions/stdio/ftell.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/stdio_rewrite/functions/stdio/ftell.c
r305 r308 32 32 #include <_PDCLIB_test.h> 33 33 34 #include <stdlib.h> 35 34 36 int main( void ) 35 37 { … … 38 40 here. 39 41 */ 42 /* The following functions delegate their tests to here: 43 fgetc fflush rewind fputc ungetc fseek 44 flushbuffer seek fillbuffer 45 */ 46 char * buffer = (char*)malloc( 4 ); 40 47 FILE * fh; 41 48 TESTCASE( ( fh = fopen( "testfile", "w+" ) ) != NULL ); 49 TESTCASE( setvbuf( fh, buffer, _IOLBF, 4 ) == 0 ); 42 50 TESTCASE( fputc( '1', fh ) == '1' ); 43 51 TESTCASE( fputc( '2', fh ) == '2' ); 44 52 TESTCASE( fputc( '3', fh ) == '3' ); 53 /* Positions incrementing as expected? */ 45 54 TESTCASE( ftell( fh ) == 3l ); 46 55 TESTCASE_NOREG( fh->offset == 0l ); 56 TESTCASE_NOREG( fh->bufidx == 3l ); 57 /* Buffer properly flushed when full? */ 58 TESTCASE( fputc( '4', fh ) == '4' ); 59 TESTCASE_NOREG( fh->offset == 4l ); 60 TESTCASE_NOREG( fh->bufidx == 0 ); 61 /* fflush() resetting positions as expected? */ 62 TESTCASE( fputc( '5', fh ) == '5' ); 47 63 TESTCASE( fflush( fh ) == 0 ); 48 TESTCASE( ftell( fh ) == 3l ); 49 TESTCASE_NOREG( fh->offset == 3l ); 64 TESTCASE( ftell( fh ) == 5l ); 65 TESTCASE_NOREG( fh->offset == 5l ); 66 TESTCASE_NOREG( fh->bufidx == 0l ); 67 /* rewind() resetting positions as expected? */ 50 68 rewind( fh ); 51 69 TESTCASE( ftell( fh ) == 0l ); 52 70 TESTCASE_NOREG( fh->offset == 0 ); 53 71 TESTCASE_NOREG( fh->bufidx == 0 ); 72 /* Reading back first character after rewind for basic read check */ 54 73 TESTCASE( fgetc( fh ) == '1' ); 55 74 TESTCASE( fclose( fh ) == 0 );
