import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class SolutionTest { @Test void basicTest() { assertEquals(4, Kumite.powerOfPrimes(123)); assertEquals(0, Kumite.powerOfPrimes(3476)); assertEquals(343, Kumite.powerOfPrimes(344338)); } @Test void onlyOdds() { assertEquals(130321, Kumite.powerOfPrimes(13537)); assertEquals(121, Kumite.powerOfPrimes(731)); assertEquals(-14, Kumite.powerOfPrimes(9311)); assertEquals(-4, Kumite.powerOfPrimes(13)); assertEquals(-50653, Kumite.powerOfPrimes(99757)); assertEquals(1, Kumite.powerOfPrimes(999)); } @Test void onlyEvens() { assertEquals(24, Kumite.powerOfPrimes(24648)); assertEquals(64, Kumite.powerOfPrimes(242)); assertEquals(1, Kumite.powerOfPrimes(888)); assertEquals(1, Kumite.powerOfPrimes(468)); assertEquals(5832, Kumite.powerOfPrimes(24822)); } @Test void negativeNumber() { assertEquals(0, Kumite.powerOfPrimes(-45)); assertEquals(0, Kumite.powerOfPrimes(-786)); assertEquals(0, Kumite.powerOfPrimes(-1)); } @Test void randomTests() { int max = 1000001; for (int i = 0; i < 1000000; i++) { int num = (int) (Math.random() * max); int expected = Kumite.powerOfPrimes(num); int actual = Kumite.powerOfPrimes(num); assertEquals(expected, actual); } } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- class SolutionTest {
- @Test
- void basicTest() {
- assertEquals(4, Kumite.powerOfPrimes(123));
assertEquals(0, Kumite.powerOfPrimes(-1));- assertEquals(0, Kumite.powerOfPrimes(3476));
- assertEquals(343, Kumite.powerOfPrimes(344338));
- }
- @Test
- void onlyOdds()
- {
- assertEquals(130321, Kumite.powerOfPrimes(13537));
- assertEquals(121, Kumite.powerOfPrimes(731));
- assertEquals(-14, Kumite.powerOfPrimes(9311));
- assertEquals(-4, Kumite.powerOfPrimes(13));
- assertEquals(-50653, Kumite.powerOfPrimes(99757));
- assertEquals(1, Kumite.powerOfPrimes(999));
- }
- @Test
- void onlyEvens()
- {
- assertEquals(24, Kumite.powerOfPrimes(24648));
- assertEquals(64, Kumite.powerOfPrimes(242));
- assertEquals(1, Kumite.powerOfPrimes(888));
- assertEquals(1, Kumite.powerOfPrimes(468));
- assertEquals(5832, Kumite.powerOfPrimes(24822));
- }
- @Test
- void negativeNumber()
- {
- assertEquals(0, Kumite.powerOfPrimes(-45));
- assertEquals(0, Kumite.powerOfPrimes(-786));
- assertEquals(0, Kumite.powerOfPrimes(-1));
- }
- @Test
- void randomTests() {
- int max = 1000001;
- for (int i = 0; i < 1000000; i++) {
- int num = (int) (Math.random() * max);
- int expected = Kumite.powerOfPrimes(num);
- int actual = Kumite.powerOfPrimes(num);
- assertEquals(expected, actual);
- }
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class SolutionTest { @Test void basicTest() { assertEquals(4, Kumite.powerOfPrimes(123)); assertEquals(1, Kumite.powerOfPrimes(-1)); assertEquals(0, Kumite.powerOfPrimes(3476)); assertEquals(343, Kumite.powerOfPrimes(344338)); } @Test void onlyOdds() { assertEquals(130321, Kumite.powerOfPrimes(13537)); assertEquals(121, Kumite.powerOfPrimes(731)); assertEquals(-14, Kumite.powerOfPrimes(9311)); assertEquals(-4, Kumite.powerOfPrimes(13)); assertEquals(-50653, Kumite.powerOfPrimes(99757)); assertEquals(1, Kumite.powerOfPrimes(999)); } @Test void onlyEvens() { assertEquals(24, Kumite.powerOfPrimes(24648)); assertEquals(64, Kumite.powerOfPrimes(242)); assertEquals(1, Kumite.powerOfPrimes(888)); assertEquals(1, Kumite.powerOfPrimes(468)); assertEquals(5832, Kumite.powerOfPrimes(24822)); } @Test void randomTests() { int max = 1000001; for (int i = 0; i < 1000000; i++) { int num = (int) (Math.random() * max); int expected = Kumite.powerOfPrimes(num); int actual = Kumite.powerOfPrimes(num); assertEquals(expected, actual); } } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- class SolutionTest {
- @Test
- void basicTest() {
- assertEquals(4, Kumite.powerOfPrimes(123));
- assertEquals(1, Kumite.powerOfPrimes(-1));
assertEquals(1, Kumite.powerOfPrimes(666));assertEquals(1, Kumite.powerOfPrimes(999));- assertEquals(0, Kumite.powerOfPrimes(3476));
- assertEquals(343, Kumite.powerOfPrimes(344338));
- }
- @Test
- void onlyOdds()
- {
- assertEquals(130321, Kumite.powerOfPrimes(13537));
- assertEquals(121, Kumite.powerOfPrimes(731));
- assertEquals(-14, Kumite.powerOfPrimes(9311));
- assertEquals(-4, Kumite.powerOfPrimes(13));
- assertEquals(-50653, Kumite.powerOfPrimes(99757));
- assertEquals(1, Kumite.powerOfPrimes(999));
- }
- @Test
- void onlyEvens()
- {
- assertEquals(24, Kumite.powerOfPrimes(24648));
- assertEquals(64, Kumite.powerOfPrimes(242));
- assertEquals(1, Kumite.powerOfPrimes(888));
- assertEquals(1, Kumite.powerOfPrimes(468));
- assertEquals(5832, Kumite.powerOfPrimes(24822));
- }
- @Test
- void randomTests() {
- int max = 1000001;
- for (int i = 0; i < 1000000; i++) {
- int num = (int) (Math.random() * max);
- int expected = Kumite.powerOfPrimes(num);
- int actual = Kumite.powerOfPrimes(num);
- assertEquals(expected, actual);
- }
- }
- }
Added test for only odds digits
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class SolutionTest { @Test void basicTest() { assertEquals(4, Kumite.powerOfPrimes(123)); assertEquals(1, Kumite.powerOfPrimes(-1)); assertEquals(1, Kumite.powerOfPrimes(666)); assertEquals(1, Kumite.powerOfPrimes(999)); assertEquals(0, Kumite.powerOfPrimes(3476)); assertEquals(343, Kumite.powerOfPrimes(344338)); } @Test void onlyOdds() { assertEquals(130321, Kumite.powerOfPrimes(13537)); assertEquals(121, Kumite.powerOfPrimes(731)); assertEquals(-14, Kumite.powerOfPrimes(9311)); assertEquals(-4, Kumite.powerOfPrimes(13)); assertEquals(-50653, Kumite.powerOfPrimes(99757)); } @Test void randomTests() { int max = 1000001; for (int i = 0; i < 1000000; i++) { int num = (int) (Math.random() * max); int expected = Kumite.powerOfPrimes(num); int actual = Kumite.powerOfPrimes(num); assertEquals(expected, actual); } } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- class SolutionTest {
- @Test
- void basicTest() {
- assertEquals(4, Kumite.powerOfPrimes(123));
- assertEquals(1, Kumite.powerOfPrimes(-1));
- assertEquals(1, Kumite.powerOfPrimes(666));
- assertEquals(1, Kumite.powerOfPrimes(999));
- assertEquals(0, Kumite.powerOfPrimes(3476));
- assertEquals(343, Kumite.powerOfPrimes(344338));
- }
- @Test
- void onlyOdds()
- {
- assertEquals(130321, Kumite.powerOfPrimes(13537));
- assertEquals(121, Kumite.powerOfPrimes(731));
- assertEquals(-14, Kumite.powerOfPrimes(9311));
- assertEquals(-4, Kumite.powerOfPrimes(13));
- assertEquals(-50653, Kumite.powerOfPrimes(99757));
- }
- @Test
- void randomTests() {
- int max = 1000001;
- for (int i = 0; i < 1000000; i++) {
- int num = (int) (Math.random() * max);
- int expected = Kumite.powerOfPrimes(num);
- int actual = Kumite.powerOfPrimes(num);
- assertEquals(expected, actual);
- }
- }
- }