test.scm 666 B

12345678910111213141516171819202122232425262728
  1. (import
  2. (scheme base)
  3. (scheme write)
  4. (scheme load)
  5. (srfi 64))
  6. (load "./solution.scm")
  7. (define test-values
  8. '(("Example 1" (#(2 7 11 15) 9) #(0 1))
  9. ("Example 2" (#(3 2 4) 6) #(1 2))
  10. ("Example 3" (#(3 3) 6) #(0 1))))
  11. (define (test-solution proc)
  12. (test-begin "Problem 1 Test Suite")
  13. (for-each (lambda (test-pair)
  14. (define name (list-ref test-pair 0))
  15. (define input (list-ref test-pair 1))
  16. (define output (list-ref test-pair 2))
  17. (define actual-output (apply proc input))
  18. (test-equal name output actual-output))
  19. test-values)
  20. (test-end))
  21. (test-solution two-sum)