/**
* Unit test cases for the implementation of a B-Tree.
*
* @author __your_name___
*/
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class BTreeTest
{
/**
* the tree to use for testing
*/
private BTree<Integer> tree;
// returns a tree loaded with the given items
static BTree<Integer> load(int order, Integer... items)
{
IntComparator compare = new IntComparator();
BTree<Integer> tree = new BTree<Integer>(order, compare);
for (Integer value : items) {
tree.add(value);
}
return tree;
}
/**
* Test the add method with tree of order 2
*/
@Test
public void test_add_2()
{
// testing empty of order 2
tree = load( 2 );
tree.add( _a_number_ );
assertEquals( tree.toString(), "[?]" );
uncomment later //assertEquals( tree.toStringSorted(), "[?]" );
// testing single tree of order 2
tree = load( 2, _a_number_ );
tree.add( _a_number_ );
assertEquals( tree.toString(), "[? ?]" );
uncomment later //assertEquals( tree.toStringSorted(), "[? ?]" );
*** one test case for single is not enough ***
*** too many test cases for single are not needed ***
// testing multi tree of order 2
tree = load( 2, s,e,v,e,r,a,l,n,u,m,b,e,r,s );
tree.add( _a_number_ );
assertEquals( multi.toString(), "[? ? ? ... ?]" );
uncomment later //assertEquals( multi.toStringSorted(), "[? ? ? ... ?]" );
*** one test case for multi may not be enough ***
}
/**
* Test the add method with tree of order 4
*/
@Test
public void test_add_4()
{
}