X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffputs.c;h=748fa5aff414ed8436951c48afed57e52f9cb36b;hb=52e702f02142dc34a476f01ca6bf8257cc9bc7e4;hp=716fef838b5ebddaba629c760c52e777f268eadb;hpb=8404f0a1339e4be015e278e83bb1a9e3f73751a3;p=pdclib.old diff --git a/functions/stdio/fputs.c b/functions/stdio/fputs.c index 716fef8..748fa5a 100644 --- a/functions/stdio/fputs.c +++ b/functions/stdio/fputs.c @@ -39,9 +39,21 @@ int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_rest #ifdef TEST #include <_PDCLIB_test.h> +#include + int main( void ) { - TESTCASE( NO_TESTDRIVER ); + FILE * fh; + char buffer[100]; + char text[] = "SUCCESS testing fputs()."; + TESTCASE( ( fh = fopen( "testfile", "w" ) ) != NULL ); + TESTCASE( fputs( text, fh ) != EOF ); + TESTCASE( fclose( fh ) == 0 ); + TESTCASE( ( fh = fopen( "testfile", "r" ) ) != NULL ); + TESTCASE( fread( buffer, 1, strlen( text ), fh ) == strlen( text ) ); + TESTCASE( memcmp( buffer, text, strlen( text ) ) == 0 ); + TESTCASE( fclose( fh ) == 0 ); + TESTCASE( remove( "testfile" ) == 0 ); return TEST_RESULTS; }