1
exercism fetch common-lisp pascals-triangle

pascals-triangle-test.lisp

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
(ql:quickload "lisp-unit")
#-xlisp-test (load "pascal")

(defpackage #:pascal-test
  (:use #:common-lisp #:lisp-unit))
(in-package #:pascal-test)

(define-test zero-rows
    (assert-equal '()
                  (pascal:rows 0)))

(define-test single-row
    (assert-equal '((1))
                  (pascal:rows 1)))

(define-test two-rows
    (assert-equal '((1) (1 1))
                  (pascal:rows 2)))

(define-test three-rows
    (assert-equal '((1) (1 1) (1 2 1))
                  (pascal:rows 3)))

(define-test four-rows
    (assert-equal '((1) (1 1) (1 2 1) (1 3 3 1))
                  (pascal:rows 4)))

(define-test negative-rows
    (assert-equal '()
                  (pascal:rows -1)))
#-xlisp-test
(let ((*print-errors* t)
      (*print-failures* t))
  (run-tests :all :pascal-test))