Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string.c test suite

For practice I decided to rewrite string.c in C. I can not find online (via google or other search engines) a test suite for either the entire standard or for specifically string.h

More specifically I am looking to see if my strcat(), strncat(), strchr(), strrchr(), strcmp(), strncmp(), strcpy(), strncpy(), strlen(), and strstr() functions conform to ISO/IEC 9899:1990 (``ISO C90'').

Can anyone recommend a good way to test these functions?

edit: the title and paragraph above used to say string.h - I meant string.c

like image 696
Good Person Avatar asked Dec 07 '25 10:12

Good Person


2 Answers

P.J. Plauger, in his book The Standard C Library (which covers implementing the whole library) presents test programs for each part of the library. These are not exhaustive, and I don't have an on-line source for them, but the book is definitely of interest to anyone implementing the library.

Compiler and library validation test suites are readily available. IIRC, Rogue Wave was in that business. But they cost money, companies that use them tend to have deep pockets.

The GNU folks have them too, this looks like a good place to start. You'll have to do some digging to isolate the string.h tests. But, don't hesitate to write these tests yourself. It strikes me as a better way to learn what the string function should and should not do than reimplementing the functions.

like image 27
Hans Passant Avatar answered Dec 10 '25 09:12

Hans Passant