@@ -0,0 +1,2861 @@
+/*%0A The MIT License%0A%0A Copyright (c) 2010-2017 Paul R. Holser, Jr.%0A%0A Permission is hereby granted, free of charge, to any person obtaining%0A a copy of this software and associated documentation files (the%0A %22Software%22), to deal in the Software without restriction, including%0A without limitation the rights to use, copy, modify, merge, publish,%0A distribute, sublicense, and/or sell copies of the Software, and to%0A permit persons to whom the Software is furnished to do so, subject to%0A the following conditions:%0A%0A The above copyright notice and this permission notice shall be%0A included in all copies or substantial portions of the Software.%0A%0A THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND,%0A EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF%0A MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND%0A NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE%0A LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION%0A OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION%0A WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%0A*/%0A%0Apackage com.pholser.junit.quickcheck;%0A%0Aimport java.math.BigInteger;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport com.pholser.junit.quickcheck.runner.JUnitQuickcheck;%0Aimport org.junit.runner.RunWith;%0A%0Aimport static java.math.BigInteger.*;%0Aimport static org.hamcrest.Matchers.*;%0Aimport static org.junit.Assert.*;%0Aimport static org.junit.Assume.*;%0A%0A@RunWith(JUnitQuickcheck.class)%0Apublic class PrimeFactorsPropertyTest %7B%0A    static class PrimeFactors %7B%0A        static List%3CBigInteger%3E of(BigInteger n) %7B%0A            List%3CBigInteger%3E primes = new ArrayList%3C%3E();%0A%0A            for (BigInteger candidate = BigInteger.valueOf(2);%0A                n.compareTo(ONE) %3E 0;%0A                candidate = candidate.add(ONE)) %7B%0A%0A                for (; n.mod(candidate).equals(ZERO); n = n.divide(candidate))%0A                    primes.add(candidate);%0A            %7D%0A%0A            return primes;%0A        %7D%0A    %7D%0A%0A    @Property(trials = 7) public void factorsPassPrimalityTest(BigInteger n) %7B%0A        assumeThat(n, greaterThan(ZERO));%0A%0A        for (BigInteger each : PrimeFactors.of(n))%0A            assertTrue(each.isProbablePrime(1000));%0A    %7D%0A%0A    @Property(trials = 7) public void factorsMultiplyToOriginal(BigInteger n) %7B%0A        assumeThat(n, greaterThan(ZERO));%0A%0A        BigInteger product = ONE;%0A        for (BigInteger each : PrimeFactors.of(n))%0A            product = product.multiply(each);%0A%0A        assertEquals(n, product);%0A    %7D%0A%0A    @Property(trials = 7) public void factorizationsAreUnique(%0A        BigInteger m,%0A        BigInteger n) %7B%0A%0A        assumeThat(m, greaterThan(ZERO));%0A        assumeThat(n, greaterThan(ZERO));%0A        assumeThat(m, not(equalTo(n)));%0A%0A        assertThat(PrimeFactors.of(m), not(equalTo(PrimeFactors.of(n))));%0A    %7D%0A%7D%0A

Add prime-factors property test