1 (uiop:define-package #:aoc-test/utils
3 (:mix #:lisp-unit2 #:aoc/utils))
4 (in-package #:aoc-test/utils)
6 (define-test test-read-input
8 (with-input-from-string (stream "hello
10 (assert-equalp '("hello" "world")
12 (with-input-from-string (stream "1
19 (assert-equalp '(1 2 3 nil 3 2 1)
20 (read-input stream :type 'integer)))
21 (with-input-from-string (stream "this
25 (assert-equalp '(1 1 1 1)
26 (read-input stream :type (lambda (line)
27 (declare (ignore line))
30 (define-test test-read-input-fields
32 (with-input-from-string (stream "A 1
39 (assert-equalp '(("A" 1)
46 (read-input-fields stream '(string integer)))))
48 (define-test test-read-input-match
50 (with-input-from-string (stream "x: 1, y: 2
53 (assert-equalp '(("x" 1 "y" 2)
56 (read-input-match stream
57 "(\\w+): (\\d+), (\\w+): (\\d+)"
58 :types '(string integer string integer)))))