3 /* setbuf( FILE *, char * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 void setbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf )
15 /* TODO: Only allowed on a "virgin" stream; add check. */
18 setvbuf( stream, buf, _IONBF, BUFSIZ );
22 setvbuf( stream, buf, _IOFBF, BUFSIZ );
29 #include <_PDCLIB_test.h>
33 /* TODO: Extend testing once setvbuf() is finished. */
35 char const * const filename = "testfile";
37 struct _PDCLIB_file_t * fh;
39 TESTCASE( ( fh = fopen( filename, "w" ) ) != NULL );
40 TESTCASE( fh->status & _PDCLIB_LIBBUFFER );
41 TESTCASE( fh->bufsize == BUFSIZ );
44 TESTCASE( fh->buffer == buffer );
45 TESTCASE( fh->bufsize == BUFFERSIZE );
47 TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOFBF );
48 TESTCASE( fclose( fh ) == 0 );
50 TESTCASE( ( fh = fopen( filename, "w" ) ) != NULL );
53 TESTCASE( fh->buffer == NULL );
54 TESTCASE( fh->bufsize == 0 );
56 TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IONBF );
57 TESTCASE( fclose( fh ) == 0 );
59 puts( " NOTEST setbuf() test driver is PDCLib-specific." );