I have created an AVL tree implementation, but as an AVL tree is quite a complex structure, I need to test it. So the question is - how can I test it?
Up to this moment I have the following tests:
basic sanity check - checks that for every node height equals max. height of child nodes + 1, balance is in [-1, 1], left child's key < this node's key < right child's key, and there are no circular references (like left child of a node is a node himself);
check that inorder traversal on an AVL tree (and on a binary search tree in the whole) will return values from the underlying set in order;
check that an AVL tree's height is strictly less than 1.44*log2(N+2)-1 (there N is number of elements) - proved by AVL tree creators;
visual check - doesn't work that well, I try to draw a tree (rootnode in the first line, his direct children on the next line, childen of rootnode's direct childen on the third line and so on), but that works only on small trees, for big trees it becomes a complete mess;
Russian wikipedia says that it is proven experimentally, that for two insertions one rebalancing needed and for five removals also one rebalancing needed, but is it really so? English wikipedia says nothing about it, and for my AVL one rebalancing needed for two insertions or for four removals, which is not quite the same.
Maybe these tests are enough, but if there are any more tests, not difficult to implement, why not do it?
A key property of an AVL tree is that each of its sub-trees is also an AVL tree. That means that covering the basic scenarios should give you a broad coverage of the AVL tree functionality.
In other words, these tests done on the smallest tree structure that allows them are the most important ones:
If your implementation passes these tests, it would probably pass them on larger trees. Note that performance and memory usage is not tested here.