Conventional testing of arithmetic function

Hi Guys,

I've implemented a set of C function style basically to perform arithmetic operation for example i have:

void mult2compl(x,y,*z,size_x,size_y,size_z);

Which basically is the implementation, at bit level of two complement multiplier
So... the question is

for this kind of function, so math function, what is the best way to design a unit test?

I need this because i'm writing code for a math library and i would to design some test code for this function.

Is there some reference i can use to test this kind of code?
The key to a good test is to try like hell to break the code. That means a few tests of the "normal" functionality and a lot of tests of abnormal functionality. With that, I'd try:

Some normal tests:
- Multiply positive and negative sized numbers that are 2-100 bits. Do this in a nested loop so it multiplies all combinations of sizes.
- Try multiplying numbers of size 0 and 1. These should both be illegal.
- Try multiplying when z isn't big enough to hold the result, when z is exactly the right size,
and when z is bigger than the result. Do this with positive and negative results.

Have fun!
But is there any bibliography which speaks about this kind of testing?
Documentation etc... i've tried in the web to find something but except slide of software engineer i haven't found anything else.
up
think you mean "bump"
I'm not aware of any such documents or reference. You could search for testing of various processors, but that's all I can think of. Two's complement multiplication isn't very difficult except when the sizes vary, as my tests suggest.
> But is there any bibliography which speaks about this kind of testing?

http://www.amazon.com/Software-Testing-Craftsmans-Approach-Fourth/dp/1466560681

http://www.amazon.com/Practitioners-Guide-Software-Test-Design/dp/158053791X

The pages have links to more books.
Topic archived. No new replies allowed.