43 lines
1.3 KiB
Common Lisp
43 lines
1.3 KiB
Common Lisp
|
(defpackage :aoc/2024/04/tests
|
||
|
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/04))
|
||
|
|
||
|
(in-package :aoc/2024/04/tests)
|
||
|
|
||
|
(define-test suite-2024-04
|
||
|
;:parent suite-2024
|
||
|
)
|
||
|
|
||
|
(define-test test-lil-xmas-state-machine
|
||
|
:parent suite-2024-04
|
||
|
(is equal (cons 0 nil) (lil-xmas-state-machine (cons 0 nil) #\a))
|
||
|
(is equal (cons 0 :x) (lil-xmas-state-machine (cons 0 nil) #\X))
|
||
|
(is equal (cons 0 :m) (lil-xmas-state-machine (cons 0 :x) #\M))
|
||
|
(is equal (cons 0 :a) (lil-xmas-state-machine (cons 0 :m) #\A))
|
||
|
(is equal (cons 1 nil) (lil-xmas-state-machine (cons 0 :a) #\S))
|
||
|
)
|
||
|
|
||
|
(define-test test-count-xmas-in-line
|
||
|
:parent suite-2024-04
|
||
|
(is = 0 (count-xmas-in-line "FOOBAR"))
|
||
|
(is = 1 (count-xmas-in-line "XMAS"))
|
||
|
(is = 2 (count-xmas-in-line "XMASZXMAS"))
|
||
|
(is = 2 (count-xmas-in-line (reverse "XMASZXMAS"))))
|
||
|
|
||
|
(define-test test-transpose
|
||
|
:parent suite-2024-04
|
||
|
(is equal (list "147" "258" "369") (transpose (list "123" "456" "789"))))
|
||
|
|
||
|
(define-test test-diagonals
|
||
|
:parent suite-2024-04
|
||
|
(is equal (list "7" "48" "159" "26" "3") (diagonals (list "123" "456" "789"))))
|
||
|
|
||
|
(define-test+run test-part1
|
||
|
:parent suite-2024-04
|
||
|
(true (equalp "18" (part1 sample-data))))
|
||
|
|
||
|
(define-test+run test-part2
|
||
|
:parent suite-2024-04
|
||
|
(true (equalp "9" (part2 sample-data2))))
|
||
|
|
||
|
|