style: include NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION (#5149)

* style: use `assertFalse` and `assertTrue`

* style: include `NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION`
This commit is contained in:
Piotr Idzik
2024-05-08 19:11:46 +02:00
committed by GitHub
parent d3bb691f59
commit d2ddec55e5
11 changed files with 47 additions and 43 deletions

View File

@ -1,14 +1,17 @@
package com.thealgorithms.bitmanipulation;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
class IsEvenTest {
@Test
void testIsEven() {
assertEquals(true, IsEven.isEven(2));
assertEquals(true, IsEven.isEven(-12));
assertEquals(false, IsEven.isEven(21));
assertTrue(IsEven.isEven(0));
assertTrue(IsEven.isEven(2));
assertTrue(IsEven.isEven(-12));
assertFalse(IsEven.isEven(21));
assertFalse(IsEven.isEven(-1));
}
}

View File

@ -1,6 +1,7 @@
package com.thealgorithms.dynamicprogramming;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
@ -8,10 +9,10 @@ class SumOfSubsetTest {
@Test
void basicCheck() {
assertEquals(false, SumOfSubset.subsetSum(new int[] {1, 2, 7, 10, 9}, 4, 14));
assertEquals(false, SumOfSubset.subsetSum(new int[] {2, 15, 1, 6, 7}, 4, 4));
assertEquals(true, SumOfSubset.subsetSum(new int[] {7, 3, 2, 5, 8}, 4, 14));
assertEquals(true, SumOfSubset.subsetSum(new int[] {4, 3, 2, 1}, 3, 5));
assertEquals(true, SumOfSubset.subsetSum(new int[] {1, 7, 2, 9, 10}, 4, 13));
assertFalse(SumOfSubset.subsetSum(new int[] {1, 2, 7, 10, 9}, 4, 14));
assertFalse(SumOfSubset.subsetSum(new int[] {2, 15, 1, 6, 7}, 4, 4));
assertTrue(SumOfSubset.subsetSum(new int[] {7, 3, 2, 5, 8}, 4, 14));
assertTrue(SumOfSubset.subsetSum(new int[] {4, 3, 2, 1}, 3, 5));
assertTrue(SumOfSubset.subsetSum(new int[] {1, 7, 2, 9, 10}, 4, 13));
}
}

View File

@ -1,6 +1,7 @@
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
@ -8,14 +9,14 @@ public class PythagoreanTripleTest {
@Test
public void Testpythagoreantriple() {
assertEquals(true, PythagoreanTriple.isPythagTriple(3, 4, 5));
assertEquals(true, PythagoreanTriple.isPythagTriple(6, 8, 10));
assertEquals(true, PythagoreanTriple.isPythagTriple(9, 12, 15));
assertEquals(true, PythagoreanTriple.isPythagTriple(12, 16, 20));
assertEquals(true, PythagoreanTriple.isPythagTriple(15, 20, 25));
assertEquals(true, PythagoreanTriple.isPythagTriple(18, 24, 30));
assertEquals(false, PythagoreanTriple.isPythagTriple(5, 20, 30));
assertEquals(false, PythagoreanTriple.isPythagTriple(6, 8, 100));
assertEquals(false, PythagoreanTriple.isPythagTriple(-2, -2, 2));
assertTrue(PythagoreanTriple.isPythagTriple(3, 4, 5));
assertTrue(PythagoreanTriple.isPythagTriple(6, 8, 10));
assertTrue(PythagoreanTriple.isPythagTriple(9, 12, 15));
assertTrue(PythagoreanTriple.isPythagTriple(12, 16, 20));
assertTrue(PythagoreanTriple.isPythagTriple(15, 20, 25));
assertTrue(PythagoreanTriple.isPythagTriple(18, 24, 30));
assertFalse(PythagoreanTriple.isPythagTriple(5, 20, 30));
assertFalse(PythagoreanTriple.isPythagTriple(6, 8, 100));
assertFalse(PythagoreanTriple.isPythagTriple(-2, -2, 2));
}
}

View File

@ -1,6 +1,7 @@
package com.thealgorithms.others;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
@ -10,34 +11,34 @@ public class TwoPointersTest {
void twoPointersFirstTestCase() {
int[] arr = {2, 6, 9, 22, 121};
int key = 28;
assertEquals(true, TwoPointers.isPairedSum(arr, key));
assertTrue(TwoPointers.isPairedSum(arr, key));
}
@Test
void twoPointersSecondTestCase() {
int[] arr = {-1, -12, 12, 0, 8};
int key = 0;
assertEquals(true, TwoPointers.isPairedSum(arr, key));
assertTrue(TwoPointers.isPairedSum(arr, key));
}
@Test
void twoPointersThirdTestCase() {
int[] arr = {12, 35, 12, 152, 0};
int key = 13;
assertEquals(false, TwoPointers.isPairedSum(arr, key));
assertFalse(TwoPointers.isPairedSum(arr, key));
}
@Test
void twoPointersFourthTestCase() {
int[] arr = {-2, 5, -1, 52, 31};
int key = -3;
assertEquals(true, TwoPointers.isPairedSum(arr, key));
assertTrue(TwoPointers.isPairedSum(arr, key));
}
@Test
void twoPointersFiftiethTestCase() {
int[] arr = {25, 1, 0, 61, 21};
int key = 12;
assertEquals(false, TwoPointers.isPairedSum(arr, key));
assertFalse(TwoPointers.isPairedSum(arr, key));
}
}

View File

@ -1,6 +1,7 @@
package com.thealgorithms.strings;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
@ -8,16 +9,16 @@ public class ValidParenthesesTest {
@Test
void testOne() {
assertEquals(true, ValidParentheses.isValid("()"));
assertTrue(ValidParentheses.isValid("()"));
}
@Test
void testTwo() {
assertEquals(true, ValidParentheses.isValid("()[]{}"));
assertTrue(ValidParentheses.isValid("()[]{}"));
}
@Test
void testThree() {
assertEquals(false, ValidParentheses.isValid("(]"));
assertFalse(ValidParentheses.isValid("(]"));
}
}