diff options
Diffstat (limited to 'report-repair/rr-test.scm')
-rw-r--r-- | report-repair/rr-test.scm | 123 |
1 files changed, 56 insertions, 67 deletions
diff --git a/report-repair/rr-test.scm b/report-repair/rr-test.scm index 7d75c09..3661c64 100644 --- a/report-repair/rr-test.scm +++ b/report-repair/rr-test.scm @@ -5,79 +5,68 @@ (test-begin "harness") -(test-equal "friendship 1" - '(1 . 2019) - (return-friendship-pair 1)) - -(test-equal "friendship 1596" - '(1596 . 424) - (return-friendship-pair 1596)) - -(test-equal "small report" - '((0 . 2020) - (1 . 2019) - (2 . 2018) - (3 . 2017) - (4 . 2016) - (5 . 2015)) - (report->pairs "0 1 2 3 4 5")) - -(test-assert "equivalent pair" - (equivalent-pair? - '(1 . 4) - '((5 . 6) - (1 . 5) - (3 . 7) - (4 . 1) - (6 . 2)))) - -(test-equal "no equivalent pair" - #f - (equivalent-pair? - '(1 . 4) - '((5 . 6) - (1 . 5) - (3 . 7) - (6 . 2)))) - -(test-equal "found equivalent pair" - '(1 . 5) - (return-equivalent-pair - '((5 . 6) - (1 . 5) - (3 . 7) - (5 . 1) - (6 . 2)))) - -(test-error "no equivalent pairs" +(test-equal "completed set size 1" + '(1 2019) + (make-complete-set '(2019))) + +(test-equal "completed set size 1" + '(366 675 979) + (make-complete-set '(675 979))) + +(test-equal "generate sets compatible" + '((675 979 366) + (366 979 675) + (979 366 675)) + (generate-sets '(979 366 675) 3)) + +(test-assert "does not include all" + (not (includes-all? '(1 2 3) '(1 2 4 5 6)))) + +(test-assert "includes all" + (includes-all? '(1 2 3) '(1 2 3 5 6))) + +(test-error "no two inputs add to 2020" #t - (return-equivalent-pair - '((5 . 6) - (1 . 5) - (3 . 7) - (6 . 2)))) + (get-2020-terms '(979 366 675) + 2)) -(test-equal "multiply pair 1" - 8 - (multiply-pair (cons 1 8))) +(test-error "2020 not present" + #t + (get-2020-terms '(1 2 3) + 1)) + +(test-equal "2020 is present" + '(2020) + (get-2020-terms '(2020 1 2 3) + 1)) + +(test-equal "three elements which add to 2020" + '(675 979 366) + (get-2020-terms '(979 366 675) + 3)) -(test-equal "multiply pair 2" - 24 - (multiply-pair (cons 3 8))) +(test-error "three elements which do not add to 2020" + #t + (get-2020-terms '(979 365 675) + 3)) -(test-equal "task-complete 1" - 1020099 - (rr "1009 237 791 478 1537 1011 1628")) +(test-equal "some two elements add to 2020" + '(299 1721) + (get-2020-terms '(1721 979 366 299 675 1456) + 2)) -(test-equal "task-complete 2" +(test-equal "some three elements add to 2020" + '(675 979 366) + (get-2020-terms '(1721 979 366 299 675 1456) + 3)) + +(test-equal "rr wrapper 2" 514579 - (rr "1721 -979 -366 -299 -675 -1456 -")) + (rr "1721 979 366 299 675 1456" 2)) + +(test-equal "rr wrapper 3" + 241861950 + (rr "1721 979 366 299 675 1456" 3)) (test-end "harness") |