-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathTreapTest.java
62 lines (55 loc) · 1.46 KB
/
TreapTest.java
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
61
62
package com.thealgorithms.datastructures.trees;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
public class TreapTest {
@Test
public void searchAndFound() {
Treap treap = new Treap();
treap.insert(5);
treap.insert(9);
treap.insert(6);
treap.insert(2);
treap.insert(3);
treap.insert(8);
treap.insert(1);
assertEquals(5, treap.search(5).value);
}
@Test
public void searchAndNotFound() {
Treap treap = new Treap();
treap.insert(5);
treap.insert(9);
treap.insert(6);
treap.insert(2);
treap.insert(3);
treap.insert(8);
treap.insert(1);
assertEquals(null, treap.search(4));
}
@Test
public void lowerBound() {
Treap treap = new Treap();
treap.insert(5);
treap.insert(9);
treap.insert(6);
treap.insert(2);
treap.insert(3);
treap.insert(8);
treap.insert(1);
assertEquals(5, treap.lowerBound(4).value);
}
@Test
public void size() {
Treap treap = new Treap();
treap.insert(5);
treap.insert(9);
treap.insert(6);
treap.insert(2);
treap.insert(3);
treap.insert(8);
treap.insert(1);
assertEquals(7, treap.size());
assertFalse(treap.isEmpty());
}
}