]> code.delx.au - gnu-emacs-elpa/blob - packages/test-simple/example/test-gcd.el
Merge commit 'd827bb511203a64da3ae5cc6910b87b7c99d233b'
[gnu-emacs-elpa] / packages / test-simple / example / test-gcd.el
1 ;;; test-simple.el --- Simple Unit Test Framework for Emacs Lisp
2 ;; Copyright (C) 2015 Free Software Foundation, Inc
3
4 ;; Author: Rocky Bernstein <rocky@gnu.org>
5 ;; URL: http://github.com/rocky/emacs-test-simple
6 ;; Keywords: unit-test
7 ;; Version: 1.0
8
9 ;; This program is free software: you can redistribute it and/or
10 ;; modify it under the terms of the GNU General Public License as
11 ;; published by the Free Software Foundation, either version 3 of the
12 ;; License, or (at your option) any later version.
13
14 ;; This program is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program. If not, see
21 ;; <http://www.gnu.org/licenses/>.
22 (require 'test-simple)
23
24 (test-simple-start)
25
26 (assert-t (load-file "./gcd.el")
27 "Can't load gcd.el - are you in the right directory?" )
28
29 (note "degenereate cases")
30
31 (assert-nil (gcd 5 -1) "using positive numbers")
32 (assert-nil (gcd -4 1) "using positive numbers, switched order")
33
34 (note "GCD computations")
35 (assert-equal 1 (gcd 3 5) "gcd(3,5)")
36 (assert-equal 8 (gcd 8 32) "gcd(8,32)")
37
38 (assert-raises error (gcd "a" 32)
39 "Passing a string value should raise an error")
40
41 (end-tests)