summaryrefslogtreecommitdiff
path: root/02/test.scm
blob: 10ee751b7322348ddc95e0076d50068dd5a1c392 (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
(import (chezscheme))

; Where the magic happens
(import (lib))

; My quick-and-dirty unit testing framework (copied for each day)
(define (run-test name proc input expected)
  (let ((result (proc input)))
    (if (= result expected)
      (printf "\x1b;[32;1mPASS\x1b;[0m: ~a\n"
              name)
      (printf "\x1b;[31;1mFAIL\x1b;[0m: ~a: got ~a, expected ~a\n"
              name result expected))))

(printf "Part 1 tests:\n")

(define (test-part1 name input expected)
  (run-test name solve-part1 input expected))

(define part1-example1
  '("5 1 9 5"
    "7 5 3"
    "2 4 6 8"))
(test-part1 "part 1 example 1"
            part1-example1 18)

(printf "Part 2 tests:\n")

(define (test-part2 name input expected)
  (run-test name solve-part2 input expected))

(define part2-example1
  '("5 9 2 8"
    "9 4 7 3"
    "3 8 6 5"))
(test-part2 "part 2 example 1"
            part2-example1 9)