Skip to content
Snippets Groups Projects
Commit 9c8e000e authored by loick.pipolo's avatar loick.pipolo
Browse files

test heap add

parent a25ec066
Branches master
Tags v2.0
No related merge requests found
package ch.hepia.structure;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
class HeapTest {
@Test
void heapMainOperations() {
BinaryHeap test = new BinaryHeap(9);
//test push()
test.push(100);
test.push(19);
test.push(36);
test.push(17);
test.push(3);
test.push(25);
test.push(1);
test.push(2);
test.push(7);
assertEquals(test.heap, new int[]{100,19,36,17,3,25,1,2,7});
//test pop()
assertEquals(test.pop(), 100);
//assertEquals(test.heap, new int[]{19,36,17,3,25,1,2,7});
//test peek()
assertEquals(test.peek(), 100);
//test exists()
assertEquals(test.exists(3), true);
//test size()
assertEquals(test.size(), 8);
//test depth()
ssertEquals(test.depth(), 4);
//test addAll
BinaryHeap test2 = new BinaryHeap(9);
List<Integer> lst = new List<Integer>();
lst.addAll(Arrays.asList(100,19,36,17,3,25,1,2,7));
test2.addAll(lst);
assertEquals(test2.heap, new int[]{100,19,36,17,3,25,1,2,7});
//test isEmpty()
BinaryHeap test3 = new BinaryHeap(9);
assertEquals(test3.isEmpty(), true);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment