;; -*- compile-command: "guile -L . rr-test.scm"; -*- (use-modules (srfi srfi-64) (rr)) (test-begin "harness") (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 (get-2020-terms '(979 366 675) 2)) (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-error "three elements which do not add to 2020" #t (get-2020-terms '(979 365 675) 3)) (test-equal "some two elements add to 2020" '(299 1721) (get-2020-terms '(1721 979 366 299 675 1456) 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" 2)) (test-equal "rr wrapper 3" 241861950 (rr "1721 979 366 299 675 1456" 3)) (test-end "harness")