views:

130

answers:

2

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

+4  A: 

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.

anon
I'll be reading the book soon - thanks for pointing it out. However this doesn't help with my testing needs ;)
Good Person
+2  A: 

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.

Hans Passant