]> code.delx.au - gnu-emacs-elpa/blob - packages/test-simple/example/gcd-tests.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / test-simple / example / gcd-tests.el
1 ;;; gcd-tests.el
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 ;;;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory (locate-library "test-simple.elc")) buffer-file-name)
23 (require 'test-simple)
24
25 (test-simple-start)
26
27 (assert-t (load-file "./gcd.el")
28 "Can't load gcd.el - are you in the right directory?" )
29
30 (note "degenereate cases")
31
32 (assert-nil (gcd 5 -1) "using positive numbers")
33 (assert-nil (gcd -4 1) "using positive numbers, switched order")
34
35 (note "GCD computations")
36 (assert-equal 1 (gcd 3 5) "gcd(3,5)")
37 (assert-equal 8 (gcd 8 32) "gcd(8,32)")
38
39 (assert-raises error (gcd "a" 32)
40 "Passing a string value should raise an error")
41
42 (end-tests)