mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 22:43:30 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -1,23 +1,20 @@
|
||||
package com.thealgorithms.searches;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BinarySearch2dArrayTest {
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestMiddle() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 6;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {1,1};
|
||||
int[] expected = { 1, 1 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(1, ans[0]);
|
||||
assertEquals(1, ans[1]);
|
||||
@ -26,13 +23,11 @@ public class BinarySearch2dArrayTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestMiddleSide() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 8;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {1,3};
|
||||
int[] expected = { 1, 3 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(1, ans[0]);
|
||||
assertEquals(3, ans[1]);
|
||||
@ -41,13 +36,11 @@ public class BinarySearch2dArrayTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestUpper() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 2;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {0,1};
|
||||
int[] expected = { 0, 1 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(0, ans[0]);
|
||||
assertEquals(1, ans[1]);
|
||||
@ -56,13 +49,11 @@ public class BinarySearch2dArrayTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestUpperSide() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 1;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {0,0};
|
||||
int[] expected = { 0, 0 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(0, ans[0]);
|
||||
assertEquals(0, ans[1]);
|
||||
@ -71,13 +62,11 @@ public class BinarySearch2dArrayTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestLower() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 10;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {2,1};
|
||||
int[] expected = { 2, 1 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(2, ans[0]);
|
||||
assertEquals(1, ans[1]);
|
||||
@ -86,13 +75,11 @@ public class BinarySearch2dArrayTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestLowerSide() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 11;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {2,2};
|
||||
int[] expected = { 2, 2 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(2, ans[0]);
|
||||
assertEquals(2, ans[1]);
|
||||
@ -101,17 +88,13 @@ public class BinarySearch2dArrayTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void BinarySearch2dArrayTestNotFound() {
|
||||
int[][] arr = { {1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9,10,11,12}};
|
||||
int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
|
||||
int target = 101;
|
||||
|
||||
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
|
||||
int[] expected = {-1,-1};
|
||||
int[] expected = { -1, -1 };
|
||||
System.out.println(Arrays.toString(ans));
|
||||
assertEquals(-1, ans[0]);
|
||||
assertEquals(-1, ans[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user