Пример #1
0
 @Test
 public void lisääminenKasvattaaKokoa() {
   int size = bintree.getSize();
   bintree.insert(5);
   int size2 = bintree.getSize();
   assertEquals(size2, size + 1);
 }
Пример #2
0
 @Test
 public void poistoPienentääKokoa() {
   int size = bintree.getSize();
   bintree.delete(15);
   int size2 = bintree.getSize();
   assertEquals(size2, size - 1);
 }
Пример #3
0
 @Test
 public void eiVoiLisätäJosOnJo() {
   int size = bintree.getSize();
   bintree.insert(3);
   int size2 = bintree.getSize();
   assertEquals(size2, size);
 }
Пример #4
0
 @Test
 public void juurenPoistoOnnistuu() {
   int size = bintree.getSize();
   bintree.delete(14);
   int size2 = bintree.getSize();
   System.out.println("--------------\nJuuren poisto: ");
   bintree.print(bintree.getRoot());
   System.out.println("--------------");
   assertEquals(size2, size - 1);
 }
Пример #5
0
 @Before
 public void setUp() {
   bintree = new BinaryTree();
   bintree.insert(14);
   bintree.insert(17);
   bintree.insert(2);
   bintree.insert(19);
   bintree.insert(15);
   bintree.insert(3);
 }
Пример #6
0
 @Test
 public void yksiLapsisenPoistoOnnistuu() {
   int size = bintree.getSize();
   bintree.delete(2);
   int size2 = bintree.getSize();
   System.out.println("--------------\nYksilapsisen poisto: ");
   bintree.print(bintree.getRoot());
   System.out.println("--------------");
   assertEquals(size2, size - 1);
 }
Пример #7
0
 @Test
 public void etsiminenEiLöydä() {
   apunode = bintree.searchBin(bintree.getRoot(), 7);
   assertEquals(null, apunode);
 }
Пример #8
0
 @Test
 public void etsiminenLöytää() {
   apunode = bintree.searchBin(bintree.getRoot(), 14);
   assertEquals(14, apunode.getKey());
 }