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