mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Add another method to check Pronic number (#5919)
This commit is contained in:
committed by
GitHub
parent
1577ec4e62
commit
871e4df0d9
@@ -1,33 +1,22 @@
|
||||
package com.thealgorithms.maths;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
public class PronicNumberTest {
|
||||
|
||||
@Test
|
||||
void testForPronicNumber() {
|
||||
// given
|
||||
int number = 30;
|
||||
|
||||
// when
|
||||
boolean result = PronicNumber.isPronic(number);
|
||||
|
||||
// then
|
||||
assertTrue(result);
|
||||
@ParameterizedTest
|
||||
@ValueSource(ints = {0, 2, 6, 12, 20, 30, 42, 110, 272, 380, 420, 1260, 2550})
|
||||
void testForPronicNumber(final int number) {
|
||||
Assertions.assertTrue(PronicNumber.isPronic(number));
|
||||
Assertions.assertTrue(PronicNumber.isPronicNumber(number));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForNonPronicNumber() {
|
||||
// given
|
||||
int number = 21;
|
||||
|
||||
// when
|
||||
boolean result = PronicNumber.isPronic(number);
|
||||
|
||||
// then
|
||||
assertFalse(result);
|
||||
@ParameterizedTest
|
||||
@ValueSource(ints = {1, 4, 21, 36, 150, 2500})
|
||||
void testForNonPronicNumber(final int number) {
|
||||
Assertions.assertFalse(PronicNumber.isPronic(number));
|
||||
Assertions.assertFalse(PronicNumber.isPronicNumber(number));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user