50 lines
1.4 KiB
Common Lisp
50 lines
1.4 KiB
Common Lisp
|
(defpackage :aoc/2024/07/tests
|
||
|
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/07))
|
||
|
|
||
|
(in-package :aoc/2024/07/tests)
|
||
|
|
||
|
(define-test suite-2024-07
|
||
|
;:parent suite-2024
|
||
|
)
|
||
|
|
||
|
|
||
|
|
||
|
(define-test+run test-part1
|
||
|
:parent suite-2024-07
|
||
|
(true (equalp "3749" (part1 sample-data))))
|
||
|
|
||
|
(define-test+run test-part2
|
||
|
:parent suite-2024-07
|
||
|
(true (equalp "11387" (part2 sample-data))))
|
||
|
|
||
|
|
||
|
(define-test test-parse-line
|
||
|
:parent suite-2024-07
|
||
|
(is equalp (make-equation :result 1 :operands '(3 2)) (parse-line "1: 2 3")))
|
||
|
|
||
|
(define-test test-mul-branch
|
||
|
:parent suite-2024-07
|
||
|
(is equalp (make-equation :result 10 :operands '(10)) (mul-branch (first sample-data)))
|
||
|
(is equalp nil (mul-branch (third sample-data))))
|
||
|
|
||
|
(define-test test-plus-branch
|
||
|
:parent suite-2024-07
|
||
|
(is equalp (make-equation :result 171 :operands '(10)) (plus-branch (first sample-data)))
|
||
|
(is equalp (make-equation :result 78 :operands '(17)) (plus-branch (third sample-data))))
|
||
|
|
||
|
(define-test test-solvedp
|
||
|
:parent suite-2024-07
|
||
|
(false (solvedp (first sample-data)))
|
||
|
(true (solvedp (make-equation :result 10 :operands '(10)))))
|
||
|
|
||
|
(define-test test-valid-equation
|
||
|
:parent suite-2024-07
|
||
|
(true (valid-equation (first sample-data)))
|
||
|
(false (valid-equation (third sample-data)))
|
||
|
)
|
||
|
|
||
|
(define-test test-concat-branch
|
||
|
:parent suite-2024-07
|
||
|
(is equalp (make-equation :result 15 :operands '(15)) (concat-branch (nth 3 sample-data)))
|
||
|
(is equalp nil (concat-branch (third sample-data))))
|