mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 15:02:46 +08:00
Refactor Code Style (#4151)
This commit is contained in:
@ -9,49 +9,49 @@ public class CalculateMaxOfMinTest {
|
||||
|
||||
@Test
|
||||
void testForOneElement() {
|
||||
int a[] = { 10, 20, 30, 50, 10, 70, 30 };
|
||||
int[] a = { 10, 20, 30, 50, 10, 70, 30 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == 70);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForTwoElements() {
|
||||
int a[] = { 5, 3, 2, 6, 3, 2, 6 };
|
||||
int[] a = { 5, 3, 2, 6, 3, 2, 6 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForThreeElements() {
|
||||
int a[] = { 10, 10, 10, 10, 10, 10, 10 };
|
||||
int[] a = { 10, 10, 10, 10, 10, 10, 10 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFourElements() {
|
||||
int a[] = { 70, 60, 50, 40, 30, 20 };
|
||||
int[] a = { 70, 60, 50, 40, 30, 20 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == 70);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFiveElements() {
|
||||
int a[] = { 50 };
|
||||
int[] a = { 50 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == 50);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSixElements() {
|
||||
int a[] = { 1, 4, 7, 9, 2, 4, 6 };
|
||||
int[] a = { 1, 4, 7, 9, 2, 4, 6 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == 9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSevenElements() {
|
||||
int a[] = { -1, -5, -7, -9, -12, -14 };
|
||||
int[] a = { -1, -5, -7, -9, -12, -14 };
|
||||
int k = CalculateMaxOfMin.calculateMaxOfMin(a);
|
||||
assertTrue(k == -1);
|
||||
}
|
||||
|
@ -9,49 +9,49 @@ public class CountFriendsPairingTest {
|
||||
|
||||
@Test
|
||||
void testForOneElement() {
|
||||
int a[] = { 1, 2, 2 };
|
||||
int[] a = { 1, 2, 2 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(3, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForTwoElements() {
|
||||
int a[] = { 1, 2, 2, 3 };
|
||||
int[] a = { 1, 2, 2, 3 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(4, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForThreeElements() {
|
||||
int a[] = { 1, 2, 2, 3, 3 };
|
||||
int[] a = { 1, 2, 2, 3, 3 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(5, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFourElements() {
|
||||
int a[] = { 1, 2, 2, 3, 3, 4 };
|
||||
int[] a = { 1, 2, 2, 3, 3, 4 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(6, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFiveElements() {
|
||||
int a[] = { 1, 2, 2, 3, 3, 4, 4 };
|
||||
int[] a = { 1, 2, 2, 3, 3, 4, 4 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(7, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSixElements() {
|
||||
int a[] = { 1, 2, 2, 3, 3, 4, 4, 4 };
|
||||
int[] a = { 1, 2, 2, 3, 3, 4, 4, 4 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(8, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSevenElements() {
|
||||
int a[] = { 1, 2, 2, 3, 3, 4, 4, 4, 5 };
|
||||
int[] a = { 1, 2, 2, 3, 3, 4, 4, 4, 5 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(9, a));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEightElements() {
|
||||
int a[] = { 1, 2, 2, 3, 3, 4, 4, 4, 5, 5 };
|
||||
int[] a = { 1, 2, 2, 3, 3, 4, 4, 4, 5, 5 };
|
||||
assertTrue(CountFriendsPairing.countFriendsPairing(10, a));
|
||||
}
|
||||
}
|
||||
|
@ -9,49 +9,49 @@ public class KadaneAlogrithmTest {
|
||||
|
||||
@Test
|
||||
void testForOneElement() {
|
||||
int a[] = { -1 };
|
||||
int[] a = { -1 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForTwoElements() {
|
||||
int a[] = { -2, 1 };
|
||||
int[] a = { -2, 1 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForThreeElements() {
|
||||
int a[] = { 5, 3, 12 };
|
||||
int[] a = { 5, 3, 12 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, 20));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFourElements() {
|
||||
int a[] = { -1, -3, -7, -4 };
|
||||
int[] a = { -1, -3, -7, -4 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFiveElements() {
|
||||
int a[] = { 4, 5, 3, 0, 2 };
|
||||
int[] a = { 4, 5, 3, 0, 2 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, 14));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSixElements() {
|
||||
int a[] = { -43, -45, 47, 12, 87, -13 };
|
||||
int[] a = { -43, -45, 47, 12, 87, -13 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, 146));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSevenElements() {
|
||||
int a[] = { 9, 8, 2, 23, 13, 6, 7 };
|
||||
int[] a = { 9, 8, 2, 23, 13, 6, 7 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, 68));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEightElements() {
|
||||
int a[] = { 9, -5, -5, -2, 4, 5, 0, 1 };
|
||||
int[] a = { 9, -5, -5, -2, 4, 5, 0, 1 };
|
||||
assertTrue(KadaneAlgorithm.max_Sum(a, 10));
|
||||
}
|
||||
}
|
||||
|
@ -9,49 +9,49 @@ public class LinkListSortTest {
|
||||
|
||||
@Test
|
||||
void testForOneElement() {
|
||||
int a[] = { 56 };
|
||||
int[] a = { 56 };
|
||||
assertTrue(LinkListSort.isSorted(a, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForTwoElements() {
|
||||
int a[] = { 6, 4 };
|
||||
int[] a = { 6, 4 };
|
||||
assertTrue(LinkListSort.isSorted(a, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForThreeElements() {
|
||||
int a[] = { 875, 253, 12 };
|
||||
int[] a = { 875, 253, 12 };
|
||||
assertTrue(LinkListSort.isSorted(a, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFourElements() {
|
||||
int a[] = { 86, 32, 87, 13 };
|
||||
int[] a = { 86, 32, 87, 13 };
|
||||
assertTrue(LinkListSort.isSorted(a, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFiveElements() {
|
||||
int a[] = { 6, 5, 3, 0, 9 };
|
||||
int[] a = { 6, 5, 3, 0, 9 };
|
||||
assertTrue(LinkListSort.isSorted(a, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSixElements() {
|
||||
int a[] = { 9, 65, 432, 32, 47, 327 };
|
||||
int[] a = { 9, 65, 432, 32, 47, 327 };
|
||||
assertTrue(LinkListSort.isSorted(a, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSevenElements() {
|
||||
int a[] = { 6, 4, 2, 1, 3, 6, 7 };
|
||||
int[] a = { 6, 4, 2, 1, 3, 6, 7 };
|
||||
assertTrue(LinkListSort.isSorted(a, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEightElements() {
|
||||
int a[] = { 123, 234, 145, 764, 322, 367, 768, 34 };
|
||||
int[] a = { 123, 234, 145, 764, 322, 367, 768, 34 };
|
||||
assertTrue(LinkListSort.isSorted(a, 2));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user