Sha256: f3adfc21b16ff6dcb7f5e61846055df79ecb7c90a033bc404c20b70bea166c47

Contents?: true

Size: 1.36 KB

Versions: 142

Compression:

Stored size: 1.36 KB

Contents

import org.junit.Test;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class PrimeFactorsTest {

    private long input;
    private List<Long> expectedOutput;

    @Parameters(name="Prime factors of {0} = {1}")
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][]{
                {1L, Arrays.asList()},
                {2L, Arrays.asList(2L)},
                {3L, Arrays.asList(3L)},
                {4L, Arrays.asList(2L, 2L)},
                {6L, Arrays.asList(2L, 3L)},
                {8L, Arrays.asList(2L, 2L, 2L)},
                {9L, Arrays.asList(3L, 3L)},
                {27L, Arrays.asList(3L, 3L, 3L)},
                {625L, Arrays.asList(5L, 5L, 5L, 5L)},
                {901255L, Arrays.asList(5L, 17L, 23L, 461L)},
                {93819012551L, Arrays.asList(11L, 9539L, 894119L)}
        });
    }

    public PrimeFactorsTest(long input, List<Long> expectedOutput) {
        this.input = input;
        this.expectedOutput = expectedOutput;
    }


    @Test
    public void test() {
        assertEquals(expectedOutput, PrimeFactors.getForNumber(input));
    }
}

Version data entries

142 entries across 142 versions & 1 rubygems

Version Path
trackler-2.0.8.42 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.41 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.40 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.39 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.38 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.37 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.36 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.35 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.34 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.33 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.32 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.31 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.30 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.29 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.28 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.27 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.26 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.24 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.23 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java
trackler-2.0.8.22 tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsTest.java