import org.junit.jupiter.api.Test; import java.util.List; import static org.junit.jupiter.api.Assertions.*; class BuildHeapTest { @Test void test1() { int[] data = {5, 4, 3, 2, 1}; List swaps = BuildHeap.getSwaps(data); assertEquals(3, swaps.size()); assertEquals(1, swaps.get(0).index1); assertEquals(4, swaps.get(0).index2); assertEquals(0, swaps.get(1).index1); assertEquals(1, swaps.get(1).index2); assertEquals(1, swaps.get(2).index1); assertEquals(3, swaps.get(2).index2); } @Test void test2() { int[] data = {1, 2, 3, 4, 5}; List swaps = BuildHeap.getSwaps(data); assertEquals(0, swaps.size()); } }