diff options
author | bd <bdunahu@operationnull.com> | 2024-08-05 14:06:25 -0600 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2024-08-05 14:06:25 -0600 |
commit | 5e5f7eb2304b9f9f2a54c163cdd79720ea8e0892 (patch) | |
tree | c47251b040ac6f554387810686c3b9cf76e574db /circular-primes/cp-test.scm | |
parent | 3324327b80a50e94843dedbb704683ee9b3a9955 (diff) |
Circular primes implementation and tests
Diffstat (limited to 'circular-primes/cp-test.scm')
-rw-r--r-- | circular-primes/cp-test.scm | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/circular-primes/cp-test.scm b/circular-primes/cp-test.scm new file mode 100644 index 0000000..2e99fe3 --- /dev/null +++ b/circular-primes/cp-test.scm @@ -0,0 +1,62 @@ +;; -*- compile-command: "guile -L . cp-test.scm"; -*- +(use-modules (srfi srfi-64) + (cp)) + + +(test-begin "harness") + + +(test-equal "rotate list empty" + '() + (list-rotate '())) + +(test-equal "rotate list singleton" + '(1) + (list-rotate '(1))) + +(test-equal "rotate list switch" + '(2 1) + (list-rotate '(1 2))) + +(test-equal "rotate list three" + '(2 3 1) + (list-rotate '(1 2 3))) + +(test-equal "rotate list four" + '(2 3 4 1) + (list-rotate '(1 2 3 4))) + +(test-equal "number->circular-list 1" + '(1) + (number->circular-list 1)) + +(test-equal "number->circular-list 12" + '(21 12) + (number->circular-list 12)) + +(test-equal "number->circular-list 123" + '(312 231 123) + (number->circular-list 123)) + +(test-equal "number->circular-list 1234" + '(4123 3412 2341 1234) + (number->circular-list 1234)) + +(test-equal "circular-primes to zero" + '() + (generate-circular-primes-to 0)) + +(test-equal "circular-primes to 2" + '(2) + (generate-circular-primes-to 2)) + +(test-equal "circular-primes to 3" + '(2 3) + (generate-circular-primes-to 3)) + +(test-equal "circular-primes to 100" + '(2 3 5 7 11 13 17 31 37 71 73 79 97) + (generate-circular-primes-to 100)) + + +(test-end "harness") |