public void MergeTest() { var testP = new ArrayQ(); var nums1 = new int[] { 1, 2, 3, 0, 0, 0 }; var m = 3; var nums2 = new int[] { 2, 5, 6 }; var n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("1 2 2 3 5 6", string.Join(" ", nums1)); nums1 = new int[] { 1, 2, 3, 0, 0, 0 }; m = 3; nums2 = new int[] { 2, 5 }; n = 2; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("1 2 2 3 5 0", string.Join(" ", nums1)); nums1 = new int[] { 6, 7, 8, 0, 0, 0 }; m = 3; nums2 = new int[] { 2, 3, 5 }; n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("2 3 5 6 7 8", string.Join(" ", nums1)); nums1 = new int[] { 6, 7, 8, 0, 0, 0 }; m = 3; nums2 = new int[] { 9, 10, 11 }; n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("6 7 8 9 10 11", string.Join(" ", nums1)); nums1 = new int[] { 6, 7, 12, 0, 0, 0 }; m = 3; nums2 = new int[] { 9, 10, 11 }; n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("6 7 9 10 11 12", string.Join(" ", nums1)); nums1 = new int[] { 6, 7, 12, 0, 0, 0 }; m = 3; nums2 = new int[] { 8, 8, 8 }; n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("6 7 8 8 8 12", string.Join(" ", nums1)); nums1 = new int[] { 8, 8, 8, 0, 0, 0 }; m = 3; nums2 = new int[] { 9, 10, 11 }; n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("8 8 8 9 10 11", string.Join(" ", nums1)); nums1 = new int[] { -1, 0, 0, 3, 3, 3, 0, 0, 0 }; m = 6; nums2 = new int[] { 1, 2, 2 }; n = 3; testP.Merge(nums1, m, nums2, n); Assert.AreEqual("-1 0 0 1 2 2 3 3 3", string.Join(" ", nums1)); }