• Advertisement
Sign in to follow this  

number of tests

This topic is 4463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've written a dynamic array class for C++, and I just recently added an insert function. I'm just wondering how many tests I should put it through to test the insert function. Would you generally do a single test for each of the special cases and then one of the general case? This is what I ended up doing. I started the list off with 5 elements (integers, 0-4) and then inserted at the end, at the start and in the middle. Do you think that these tests would be enough considering that I have already tested the rest of the class and have confirmed it's correctness?

Share this post


Link to post
Share on other sites
Advertisement
I'd also throw in a test with a class type to make sure that you aren't leaking memory or double deleting or similar non-kosherness.

Share this post


Link to post
Share on other sites
Do you have removal operations as well?
Don't forget to gracefully handle attempts to do stupid things such as pop_front with no items in the array.

[grin]!I think the best test is posting it on a message board and let 1000s of others pick holes in it![grin]

Share this post


Link to post
Share on other sites
All the other functions (push_back, erase, resize, etc) have been written and are working and I'm actually using it in my current project, a simple graphics engine.

It's just that I've always used push_back or just resized it and accessed the elements manually, because there's never been a need for anything else.

So, it was just on the insert function I was wondering about the number of tests.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endar
I've written a dynamic array class for C++...

Everyone already knows that I'm going to post it and I'd hate to disappoint, so without further ado:

Why? What's wrong with std::vector?

Enigma

Share this post


Link to post
Share on other sites
Absolutely nothing.

There was a fairly good reason as to why I was using it early on that I can't remember as it is midnight here, but later on it just became ingrained with the rest of my code, and since it was all working, I couldn't really find a compelling reason to go and re-write a whole bunch of code for what seemed to be fairly negligible rewards.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement