diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/BuildHeapTest.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/BuildHeapTest.java b/src/test/BuildHeapTest.java new file mode 100644 index 0000000..59b1711 --- /dev/null +++ b/src/test/BuildHeapTest.java @@ -0,0 +1,28 @@ +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<BuildHeap.Swap> 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<BuildHeap.Swap> swaps = BuildHeap.getSwaps(data); + assertEquals(0, swaps.size()); + } + +}
\ No newline at end of file |