(defpackage :aoc/2024/14/tests (:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/14)) (in-package :aoc/2024/14/tests) (define-test suite-2024-14 ;:parent suite-2024 ) (define-test test-parse-line :parent suite-2024-14 (is equalp (make-robot :px 0 :py 4 :vx 3 :vy -3) (parse-line "p=0,4 v=3,-3" )) ) (define-test test-robot-position :parent suite-2024-14 (let ((r (make-robot :px 2 :py 4 :vx 2 :vy -3)) (g #(11 7))) (is equalp (robot-at-position r #(4 1)) (robot-at-time r 1 g)) (is equalp (robot-at-position r #(6 5)) (robot-at-time r 2 g)) (is equalp (robot-at-position r #(8 2)) (robot-at-time r 3 g)) (is equalp (robot-at-position r #(10 6)) (robot-at-time r 4 g)) (is equalp (robot-at-position r #(1 3)) (robot-at-time r 5 g)) (is equalp (robot-at-position r #(4 5)) (robot-at-time r 100 g)) )) (define-test test-quadrant :parent suite-2024-14 (false (quadrant #(5 1) #(11 7))) (false (quadrant #(8 3) #(11 7))) (is = 0 (quadrant #(0 0) #(11 7))) (is = 1 (quadrant #(7 2) #(11 7))) (is = 2 (quadrant #(4 4) #(11 7))) (is = 3 (quadrant #(6 4) #(11 7))) ) (define-test test-safety-factor :parent suite-2024-14 (is = 12 (safety-factor sample-data #(11 7))) ) (define-test+run test-part1 :parent suite-2024-14 (is equal "12" (part1 sample-data #(11 7))))