diff options
Diffstat (limited to 'sieve-of-eratosthenes/soe-test.scm')
-rw-r--r-- | sieve-of-eratosthenes/soe-test.scm | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/sieve-of-eratosthenes/soe-test.scm b/sieve-of-eratosthenes/soe-test.scm new file mode 100644 index 0000000..69dfaf2 --- /dev/null +++ b/sieve-of-eratosthenes/soe-test.scm @@ -0,0 +1,59 @@ +;; -*- compile-command: "guile -L . soe-test.scm"; -*- +(use-modules (srfi srfi-64) + (soe)) + + +(test-begin "harness") + + +(test-equal "generate-initial-lst none" + '() + (generate-initial-lst 0)) + +(test-equal "generate-initial-lst two" + '() + (generate-initial-lst 2)) + +(test-equal "generate-initial-lst four" + '(3) + (generate-initial-lst 4)) + +(test-equal "generate-initial-lst five" + '(3 5) + (generate-initial-lst 5)) + +(test-equal "generate-initial-lst six" + '(3 5) + (generate-initial-lst 6)) + +(test-equal "generate-initial-lst 15" + '(3 5 7 9 11 13 15) + (generate-initial-lst 15)) + +(test-equal "generate-primes-to none" + '() + (generate-primes-to 0)) + +(test-equal "generate-primes-to two" + '(2) + (generate-primes-to 2)) + +(test-equal "generate-primes-to three" + '(2 3) + (generate-primes-to 3)) + +(test-equal "generate-primes-to nine" + '(2 3 5 7) + (generate-primes-to 9)) + +(test-equal "generate-primes-to thirteen" + '(2 3 5 7 11 13) + (generate-primes-to 13)) + +(test-equal "generate-primes-to 977 is 165th" + '(977 . 165) + (let ((primes (reverse (generate-primes-to 980)))) + (cons (car primes) (length primes)))) + + +(test-end "harness") |