-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerformanceTests.java
More file actions
51 lines (39 loc) · 1.17 KB
/
Copy pathPerformanceTests.java
File metadata and controls
51 lines (39 loc) · 1.17 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
// package tests;
/**
* Test cases related to binary search tree performance.
*
* @author Kyle Sadler
* @version 1.0
* @since 2018-10-03
*/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import java.lang.Math;
public class PerformanceTests {
@Test(timeout=10)
public void Adding10000DescendingNumbersShouldTakeLessThan5Ms() {
AVLTree tree = new AVLTree();
Object anObject = new Object();
for(int i = 10000; i > 0; i--){
tree.insert(i, anObject);
}
}
@Test(timeout=10)
public void Adding10000AscendingNumbersShouldTakeLessThan5Ms() {
AVLTree tree = new AVLTree();
Object anObject = new Object();
for(int i = 0; i < 10000; i++){
tree.insert(i, anObject);
}
}
@Test(timeout=10)
public void HeightShouldBeLessThanLogNAfterAdding10000AscendingNumbers() {
AVLTree tree = new AVLTree();
Object anObject = new Object();
for(int i = 0; i < 10000; i++){
tree.insert(i, anObject);
}
assertTrue(tree.getHeight() < Math.log(10000)/Math.log(2) + 1);
}
}