|
@@ -3,18 +3,18 @@ package com.garypaduana.groovytools.algorithm
|
|
|
import com.garypaduana.groovytools.system.Timing
|
|
import com.garypaduana.groovytools.system.Timing
|
|
|
import spock.lang.Specification
|
|
import spock.lang.Specification
|
|
|
|
|
|
|
|
-class TestFermatsLittleTheorm extends Specification{
|
|
|
|
|
|
|
+class TestFermatsLittleTheorem extends Specification{
|
|
|
|
|
|
|
|
def "test with known prime"(){
|
|
def "test with known prime"(){
|
|
|
when:
|
|
when:
|
|
|
- def result = Timing.timeIt({FermatsLittleTheorm.probablyPrime(15485867)})
|
|
|
|
|
|
|
+ def result = Timing.timeIt({FermatsLittleTheorem.probablyPrime(15485867)})
|
|
|
then:
|
|
then:
|
|
|
result.returnValue == true
|
|
result.returnValue == true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
def "test with known composite"(){
|
|
def "test with known composite"(){
|
|
|
when:
|
|
when:
|
|
|
- def result = Timing.timeIt({FermatsLittleTheorm.probablyPrime(2398932)})
|
|
|
|
|
|
|
+ def result = Timing.timeIt({FermatsLittleTheorem.probablyPrime(2398932)})
|
|
|
then:
|
|
then:
|
|
|
result.returnValue == false
|
|
result.returnValue == false
|
|
|
}
|
|
}
|