From 82f7a6c75aed94e7e72830a066ea10253fb6384c Mon Sep 17 00:00:00 2001 From: TINO Date: Mon, 23 Dec 2019 18:22:40 +0300 Subject: [PATCH] BAEL - 3482 --- ...pmergeUnitTest.java => MinHeapMergeUnitTest.java} | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) rename algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/{MinHeapmergeUnitTest.java => MinHeapMergeUnitTest.java} (74%) diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapmergeUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapMergeUnitTest.java similarity index 74% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapmergeUnitTest.java rename to algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapMergeUnitTest.java index 1d80651f92..6e4b8421c6 100644 --- a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapmergeUnitTest.java +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapMergeUnitTest.java @@ -6,29 +6,33 @@ import static org.junit.Assert.assertThat; import org.junit.Test; -public class MinHeapmergeUnitTest { +public class MinHeapMergeUnitTest { private final int[][] inputArray = { { 0, 6 }, { 1, 5, 10, 100 }, { 2, 4, 200, 650 } }; private final int[] expectedArray = { 0, 1, 2, 4, 5, 6, 10, 100, 200, 650 }; @Test - public void givenSortedArraysWhenMergedShouldReturnASingleSortedarray() { + public void givenSortedArrays_whenMerged_thenShouldReturnASingleSortedarray() { int[] resultArray = MinHeapMerge.merge(inputArray); + assertThat(resultArray.length, is(equalTo(10))); assertThat(resultArray, is(equalTo(expectedArray))); } @Test - public void givenEmptyHeapNodesAndInputArrayWhenPopulatedShouldPopulateAndReturnResultArrayLength() { + public void givenEmptyHeapNodesAndInputArray_whenPopulated_thenShouldPopulateAndReturnResultArrayLength() { int size = MinHeapMerge.populateHeapNodesAndDetermineResultingArrayLength(inputArray, new HeapNode[inputArray.length]); + assertThat(size, is(equalTo(10))); } @Test - public void givenArrayAndHeapNodesAndResultArraySizeWhenMergedShouldReturnASingleSortedarray() { + public void givenArrayAndHeapNodesAndResultArraySize_whenMerged_thenShouldReturnASingleSortedarray() { HeapNode[] heapNodes = new HeapNode[inputArray.length]; int size = MinHeapMerge.populateHeapNodesAndDetermineResultingArrayLength(inputArray, heapNodes); + int[] resultArray = MinHeapMerge.createMinHeapAndMergeArrays(inputArray, heapNodes, size); + assertThat(resultArray.length, is(equalTo(10))); assertThat(resultArray, is(equalTo(expectedArray))); }