TDDを求めるエンジニアが多いので、gaucheでのユニットテスト例。
;;テスト対象
(define (proc1 a b c)
(if (and (<= a b)(<= a c))
(+ (proc2 b)(proc2 c))
(proc1 b c a)))(define (proc2 x)
(* x x))#|
以下ユニットテスト例。
|#
;;テストモジュールを読み込む
(use gauche.test);;テストをスタート
(test-start "proc1 test");;テスト群の名前付け。
(test-section "test group 1");;テスト項目
(test* "proc1 13" 13 (proc1 1 2 3))
(test* "proc1 25" 25 (proc1 2 4 3))
(test* "proc1 41" 41 (proc1 5 4 3))
(test* "proc1 2" 2 (proc1 1 1 1));;テストの終了
(test-end)
実行結果
Testing proc1 test ...
<test group 1>-----------------------------------------------------------------
test proc1 13, expects 13 ==> ok
test proc1 25, expects 25 ==> ok
test proc1 41, expects 41 ==> ok
test proc1 2, expects 2 ==> ok
passed.
