summaryrefslogtreecommitdiff
path: root/combinations/combinations-test.scm
blob: 0f1423dc9a2e2a2d21b5185086ecf2a31168250e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
;; -*- compile-command: "guile -L . combinations-test.scm"; -*-
(use-modules (srfi srfi-64)
             (combinations))

(test-begin "harness")


(test-equal "zero combinations"
  '(())
  (combinations '(1 2 3 4 5) 0))

(test-equal "single combinations"
  '((1) (2) (3) (4) (5))
  (combinations '(1 2 3 4 5) 1))

(test-equal "double combinations"
  '((1 2) (1 3) (1 4) (1 5)
    (2 3) (2 4) (2 5)
    (3 4) (3 5)
    (4 5))
  (combinations '(1 2 3 4 5) 2))

(test-equal "triple combinations"
  '((1 2 3) (1 2 4) (1 2 5) (1 3 4) (1 3 5) (1 4 5)
    (2 3 4) (2 3 5) (2 4 5)
    (3 4 5))
  (combinations '(1 2 3 4 5) 3))

(test-equal "quadruple combinations"
  '((1 2 3 4) (1 2 3 5) (1 2 4 5) (1 3 4 5) (2 3 4 5))
  (combinations '(1 2 3 4 5) 4))

(test-equal "quintuple combinations"
  '((1 2 3 4 5))
  (combinations '(1 2 3 4 5) 5))

(test-equal "combinations numbers"
  '((979 366)
    (979 675)
    (366 675))
  (combinations '(979 366 675) 2))

(test-end "harness")