How to test string library functions ?

C

codefixer

Hi,

Does anybody know how to test string library functions ?
I have already gone through
"gcc-3.4.1/gcc/testsuite/gcc.c-torture/execute" I want to know if
their is any other way to test the same.


Thanks.
 
R

Raghu Uppalli

what exactly do you intend to test? Do you want to test if they behave
as advertised?
 
C

codefixer

Raghu said:
what exactly do you intend to test? Do you want to test if they behave
as advertised?

Yes their functionality. How do you test strlen ? Can the string be
varied from 0 through n ? OR Is their any other way of doing it ?
Please feel free to share your thoughts.
 
H

Howard

Yes their functionality. How do you test strlen ? Can the string be
varied from 0 through n ? OR Is their any other way of doing it ?
Please feel free to share your thoughts.

I don't know why you'd want to do such a test, but you know what it's
supposed to do, right? So feed it some data and see if it gets the right
answers. Test the empty string (just a null terminator in the first
position). Test a bunch of strings whose length you know. Or make a large
array, and loop through making it adding one character and testing the
strlen function on it each time. There is no standard for such a test. And
testing will only tell you that the test did not fail... it will not prove
the correctness of the code. Seems like a waste of time to me, since the
C++ compiler vendor had already done all that testing for you, at least if
they're worth their salt! I pretty much rely on the correctness of my C++
library and STL, otherwise I'd never be able to trust my own code, since it
relies on what I've been provided as a tool base.

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top