How to unit test internals (organization) of a data structure?
Posted
by Herms
on Stack Overflow
See other posts from Stack Overflow
or by Herms
Published on 2010-04-05T13:45:27Z
Indexed on
2010/04/05
14:23 UTC
Read the original article
Hit count: 292
data-structures
|unit-testing
I've started working on a little ruby project that will have sample implementations of a number of different data structures and algorithms. Right now it's just for me to refresh on stuff I haven't done for a while, but I'm hoping to have it set up kind of like Ruby Koans, with a bunch of unit tests written for the data structures but the implementations empty (with full implementations in another branch). It could then be used as a nice learning tool or code kata.
However, I'm having trouble coming up with a good way to write the tests. I can't just test the public behavior as that won't necessarily tell me about the implementation, and that's kind of important here. For example, the public interfaces of a normal BST and a Red-Black tree would be the same, but the RB Tree has very specific data organization requirements. How would I test that?
© Stack Overflow or respective owner