UNB/ CS/ David Bremner/ teaching/ cs4613/ tutorials/ Testing in racket

Unit Tests in Racket

Prerequisites
recursion, modules

This part is based on an example from RackUnit QuickStart. The Beautiful Racket unit test explainer is a better reference, since we'll skip some of the fancier features of rackunit and move straight to having a test submodule.

#lang racket/base

(define (my-+ a b)
  (if (zero? a)
      b
      (my-+ (sub1 a) (add1 b))))

(define (my-* a b)
  (if (zero? a)
      b
      (my-* (sub1 a) (my-+ b b))))

(provide my-+
         my-*)


Test Coverage