Merge branch 'bug/133' into for-steve
[sxemacs] / tests / automated / inplace-tests.el
1 ;;;  inplace-tests.el -- Regression Tests for in-place mapping
2 ;; Copyright (C) 2006 Sebastian Freundt
3 ;;
4 ;; Author: Sebastian Freundt <hroptatyr@sxemacs.org>
5 ;; Keywords: tests
6 ;;
7 ;; This file is part of SXEmacs.
8 ;; 
9 ;; SXEmacs is free software: you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published by the
11 ;; Free Software Foundation, either version 3 of the License, or (at your
12 ;; option) any later version.
13
14 ;; SXEmacs is distributed in the hope that it will be
15 ;; useful, but 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 <http://www.gnu.org/licenses/>. 
21 ;;
22 ;;; Synched up with: Not in FSF.
23 ;;
24 ;;; Commentary:
25 ;;
26 ;; See test-harness.el for instructions on how to run these tests.
27
28 (eval-when-compile
29   (condition-case nil
30       (require 'test-harness)
31     (file-error
32      (push "." load-path)
33      (when (and (boundp 'load-file-name) (stringp load-file-name))
34        (push (file-name-directory load-file-name) load-path))
35      (require 'test-harness))))
36
37 (let ((ilist '(1 2 3 4))
38       (idllist (dllist 1 2 3 4))
39       (ivector [1 2 3 4])
40       (istring "abcdef")
41       (ibvec (bit-vector 0 1 0 1 1)))
42
43   (mapc-inplace #'1+ ilist)
44   (Assert (listp ilist))
45   (Assert (= (nth 0 ilist) 2))
46   (Assert (= (nth 3 ilist) 5))
47
48   (mapc-inplace #'1- idllist)
49   (Assert (dllistp idllist))
50   (Assert (= (dllist-car idllist) 0))
51   (Assert (= (dllist-rac idllist) 3))
52
53   (mapc-inplace #'evenp ivector)
54   (Assert (vectorp ivector))
55   (Assert-Equal ivector [nil t nil t])
56
57   ;; we can't test strings at the moment
58
59   (mapc-inplace #'zerop ibvec)
60   (Assert (bit-vector-p ibvec))
61   (Assert (= (aref ibvec 0) 1))
62   (Assert (= (aref ibvec 1) 0))
63   (Assert (= (aref ibvec 2) 1))
64   (Assert (= (aref ibvec 3) 0))
65   (Assert (= (aref ibvec 4) 0))
66
67 )
68
69 ;;; inplace-tests.el ends here