;; Copyright (C) 1999 Free Software Foundation, Inc. ;; Author: Hrvoje Niksic ;; Maintainer: Hrvoje Niksic ;; Created: 1999 ;; Keywords: tests ;; This file is part of XEmacs. ;; XEmacs is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; XEmacs is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with XEmacs; see the file COPYING. If not, write to the Free ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ;; 02111-1307, USA. ;;; Synched up with: Not in FSF. ;;; Commentary: ;; Test some Mule functionality (most of these remain to be written) . ;; See test-harness.el for instructions on how to run these tests. ;;----------------------------------------------------------------- ;; Test whether all legal chars may be safely inserted to a buffer. ;;----------------------------------------------------------------- (defun test-chars (&optional for-test-harness) "Insert all characters in a buffer, to see if XEmacs will crash. This is done by creating a string with all the legal characters in [0, 2^19) range, inserting it into the buffer, and checking that the buffer's contents are equivalent to the string. If FOR-TEST-HARNESS is specified, a temporary buffer is used, and the Assert macro checks for correctness." (let ((max (expt 2 (if (featurep 'mule) 19 8))) (list nil) (i 0)) (while (< i max) (and (not for-test-harness) (zerop (% i 1000)) (message "%d" i)) (and (int-char i) ;; Don't aset to a string directly because random string ;; access is O(n) under Mule. (setq list (cons (int-char i) list))) (setq i (1+ i))) (let ((string (apply #'string (nreverse list)))) (if for-test-harness ;; For use with test-harness, use Assert and a temporary ;; buffer. (with-temp-buffer (insert string) (Assert (equal (buffer-string) string))) ;; For use without test harness: use a normal buffer, so that ;; you can also test whether redisplay works. (switch-to-buffer (get-buffer-create "test")) (erase-buffer) (buffer-disable-undo) (insert string) (assert (equal (buffer-string) string)))))) ;; It would be really *really* nice if test-harness allowed a way to ;; run a test in byte-compiled mode only. It's tedious to have ;; time-consuming tests like this one run twice, once interpreted and ;; once compiled, for no good reason. (test-chars t)