forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryTreeTest.java
More file actions
60 lines (52 loc) · 1.61 KB
/
Copy pathBinaryTreeTest.java
File metadata and controls
60 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package src.main.java.com.dataStructures;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author RICARDO
*/
public class BinaryTreeTest {
public BinaryTreeTest() {
}
/**
* Test of insert method, of class BinaryTree.
*/
@Test
public void testInsert_BinaryTree() {
System.out.println("insert");
BinaryTree<String> lowerdata = new BinaryTree<>("1");
BinaryTree<String> upperdata = new BinaryTree<>("3");
BinaryTree<String> instance = new BinaryTree<>("2");
instance.insert(lowerdata);
instance.insert(upperdata);
String proof = instance.getLeft().toString()+instance.toString()+instance.getRight().toString();
System.out.println(proof);
assertEquals("123", proof);
}
/**
* Test of search method, of class BinaryTree.
*/
@Test
public void testSearch() {
System.out.println("search");
BinaryTree<Integer> instance = new BinaryTree<>(5);
for (int i = 1; i < 10; i++) {
instance.insert(new Integer(i));
}
BinaryTree result = instance.search(new Integer(1));
assertEquals(new Integer(1), result.getData());
}
/**
* Test of contains method, of class BinaryTree.
*/
@Test
public void testContains() {
System.out.println("contains");
BinaryTree<Integer> instance = new BinaryTree<>(5);
for (int i = 1; i < 10; i++) {
instance.insert(i);
}
boolean result = instance.contains(2)&&instance.contains(11);
assertEquals(false, result);
}
}