number of tests
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?
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.
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]
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]
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.
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.
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
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement