Hello All,

Is there any way to completely test a Circular Queue Implementation?I have written an array based implementation and need to know if it works for all the cases.I was just wondering how to come up with exhaustive set of test cases to test the code instead of the usual trial and error method.Thanks in advance.

Recommended Answers

All 2 Replies

This depends on what operations you have implemented to your structure. I don't really see why you would make an array-based queue circularly linked in the first place. For all I know, a queue works like "first in - first out". Pretty much like a stack, but you pop elements from the other end. Now if it really is a queue you're looking to test, then all I can think of is that you make some insertions like. Make retrievals until your queue casts NoElementsInQueue exception or whatever you make it do. Check how many elements you got back, and se if you got the im the right order etc.

I suspect however that you meant a circularly linked LIST structure instead right? This would make the circular implementation somewhat meaningful. A way to test such a structure should see that errors are handled correctly when you operate on an empty list. The most critical part would the be the joint between "the first" and "the last" element (this only applies as long as you keep an array). Make sure you make insertions, removals and whatever in these critical pionts. Also make attemts to iterate over your list past its length.

I also suggest looking for other ways to implement your circular list other than arrays. Using an array for a circular list makes the circular part lose some of its meaning.

I realise now I didn't provide a direct answer to your question. Well, I guess that's just because I'm a little confused of what your purpose really is. Still, I hope you found this somewhat useful, and I wish you good luck!

Emil Olofsson

Thanks for the reply.I will look into the suggestions given by you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.