Test programs according to good software engineering principles.
Consider the following not-yet-implemented procedure.
;;; (median numbers) -> real?
;;; numbers : list-of real?
;;; Find the median of a list of a nonempty list of numbers using
;;; the standard approach.
(define median
(lambda (numbers)
(car numbers))) ; Incorrect, but a good placeholder.
Write a set of tests for median. Your tests should have informative descriptions, and cover a wide variety of situations. Make sure to include at least three “expected” cases and at least three “edge” cases.
Remember that none of your tests should not attempt to find an error, meaning that the input parameters you test should be valid according to the documentation.
Here are some examples to get you started.
(test-case "an easy list of integers"
equal? 2
(lambda () (median (list 1 2 3))))
(test-case "a list of exact and inexact numbers of even length"
equal? 2.5
(lambda () (median (list 1.0 2 3 4))))