summaryrefslogtreecommitdiff
path: root/circular-primes/cp-test.scm
diff options
context:
space:
mode:
Diffstat (limited to 'circular-primes/cp-test.scm')
-rw-r--r--circular-primes/cp-test.scm62
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")