(defpackage :aoc/2024/21/tests
(:use :cl :aoc :aoc/tests :aoc/maze :aoc/2024/tests :parachute :aoc/2024/21))
(in-package :aoc/2024/21/tests)
(define-test suite-2024-21
;:parent suite-2024
)
(define-test test-key-to-pos
:parent suite-2024-21
(is equalp (make-pos :x 1 :y 0) (key-to-pos #\0))
(is equalp (make-pos :x 2 :y 0) (key-to-pos #\A))
(is equalp (make-pos :x 0 :y 1) (key-to-pos #\1))
(is equalp (make-pos :x 1 :y 2) (key-to-pos #\5))
(is equalp (make-pos :x 2 :y 3) (key-to-pos #\9))
(is equalp (make-pos :x 1 :y 0) (key-to-pos #\^))
(is equalp (make-pos :x 0 :y 1) (key-to-pos #\<))
(is equalp (make-pos :x 1 :y 1) (key-to-pos #\v))
(is equalp (make-pos :x 2 :y 1) (key-to-pos #\>))
)
(define-test test-press-key
:parent suite-2024-21
(is equal "^^A" (press-key #\2 #\9))
(is equal "vvvA" (press-key #\9 #\A))
)
(define-test test-type-code
:parent suite-2024-21
(is equal "^^AvvvA" (type-code "029A"))
(is equal "v<>^AAvA^Av^A" (type-code (type-code "029A") nil)))
(define-test test-complexity
:parent suite-2024-21
(is = (* 68 29) (complexity "029A" 2))
(is = (* 60 980) (complexity "980A" 2))
(is = (* 68 179) (complexity "179A" 2))
(is = (* 64 456) (complexity "456A" 2))
(is = (* 64 379) (complexity "379A" 2)))
(define-test test-manual
:parent suite-2024-21
(is equal
">^AvA^A>^AAvA<^A>AAvA^A^AAAA>^AAAvA<^A>A"
(type-manual "379A" 2)))
(define-test+run test-part1
:parent suite-2024-21
(is equal 126384 (part1 sample-data)))
(define-test+run test-part2
:parent suite-2024-21
(is equal nil (part2 sample-data)))