Mercurial > hg > xemacs-beta
annotate tests/automated/query-coding-tests.el @ 4596:4fc32a3a086e
Fix a couple of bugs, #'query-coding-region, #'query-coding-string.
2009-02-04 Aidan Kehoe <kehoea@parhasard.net>
* coding.el (query-coding-region):
Revert this to being a defun, add a compiler macro without
needless binding.
(query-coding-string):
Correct a bug here, string indices are zero- not one-based.
* mule/general-late.el (unicode-query-coding-skip-chars-arg):
Correct the algorithm used to initialise this variable.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 04 Feb 2009 12:14:38 +0000 |
parents | e6a7054a9c30 |
children | e0a8715fdb1f |
rev | line source |
---|---|
4568
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
1 ;; Copyright (C) 2008 Free Software Foundation, Inc. -*- coding: iso-8859-1 -*- |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
2 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
3 ;; Author: Aidan Kehoe <kehoea@parhasard.net> |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
4 ;; Maintainer: Aidan Kehoe <kehoea@parhasard.net> |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
5 ;; Created: 2008 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
6 ;; Keywords: tests, query-coding-region |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
7 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
8 ;; This file is part of XEmacs. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
9 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
11 ;; under the terms of the GNU General Public License as published by |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
13 ;; any later version. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
14 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
15 ;; XEmacs is distributed in the hope that it will be useful, but |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
18 ;; General Public License for more details. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
19 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
23 ;; 02111-1307, USA. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
24 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
25 ;;; Synched up with: Not in FSF. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
26 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
27 ;;; Commentary: |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
28 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
29 ;; Test the query-coding-region and query-coding-string implementations for |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
30 ;; some well-known coding systems. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
31 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
32 (require 'bytecomp) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
33 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
34 (defun q-c-debug (&rest aerger) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
35 (let ((standard-output (get-buffer-create "query-coding-debug")) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
36 (fmt (condition-case nil |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
37 (and (stringp (first aerger)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
38 (apply #'format aerger)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
39 (error nil)))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
40 (if fmt |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
41 (progn |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
42 (princ (apply #'format aerger)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
43 (terpri)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
44 (princ "--> ") |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
45 (let ((i 1)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
46 (dolist (sgra aerger) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
47 (if (> i 1) (princ " ")) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
48 (princ (format "%d. " i)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
49 (prin1 sgra) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
50 (incf i)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
51 (terpri))))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
52 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
53 ;; Comment this out if debugging: |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
54 (defalias 'q-c-debug #'ignore) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
55 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
56 (when (featurep 'mule) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
57 (let ((ascii-chars-string (apply #'string |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
58 (loop for i from #x0 to #x7f |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
59 collect (int-to-char i)))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
60 (latin-1-chars-string (apply #'string |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
61 (loop for i from #x0 to #xff |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
62 collect (int-to-char i)))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
63 unix-coding-system text-conversion-error-signalled) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
64 (with-temp-buffer |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
65 (insert ascii-chars-string) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
66 ;; First, check all the coding systems that are ASCII-transparent for |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
67 ;; ASCII-transparency in the check. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
68 (dolist (coding-system |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
69 (delete-duplicates |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
70 (mapcar #'(lambda (coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
71 (unless (coding-system-alias-p coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
72 ;; We're only interested in the version with |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
73 ;; Unix line endings right now. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
74 (setq unix-coding-system |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
75 (subsidiary-coding-system |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
76 (coding-system-base coding-system) 'lf)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
77 (when (and |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
78 ;; ASCII-transparent |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
79 (equal ascii-chars-string |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
80 (encode-coding-string |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
81 ascii-chars-string |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
82 unix-coding-system)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
83 (not |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
84 (memq (coding-system-type |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
85 unix-coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
86 '(undecided chain)))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
87 unix-coding-system))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
88 (coding-system-list nil)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
89 :test #'eq)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
90 (q-c-debug "looking at coding system %S" (coding-system-name |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
91 coding-system)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
92 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
93 (query-coding-region (point-min) (point-max) coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
94 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
95 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
96 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
97 (query-coding-string ascii-chars-string coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
98 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
99 (Assert (null query-coding-table)))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
100 (delete-region (point-min) (point-max)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
101 ;; Check for success from the two Latin-1 coding systems |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
102 (insert latin-1-chars-string) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
103 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
104 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
105 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
106 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
107 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
108 (query-coding-string (buffer-string) 'iso-8859-1-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
109 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
110 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
111 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
112 (query-coding-string (buffer-string) 'iso-latin-1-with-esc-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
113 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
114 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
115 ;; Make it fail, check that it fails correctly |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
116 (insert (decode-char 'ucs #x20AC)) ;; EURO SIGN |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
117 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
118 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
119 (Assert (null query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
120 (Assert (equal query-coding-table |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
121 #s(range-table type start-closed-end-open data |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
122 ((257 258) t))))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
123 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
124 (query-coding-region (point-min) (point-max) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
125 'iso-latin-1-with-esc-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
126 ;; Stupidly, this succeeds. The behaviour is compatible with |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
127 ;; GNU, though, and we encourage people not to use |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
128 ;; iso-latin-1-with-esc-unix anyway: |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
129 (Assert query-coding-succeeded) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
130 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
131 ;; Check that it errors correctly. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
132 (setq text-conversion-error-signalled nil) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
133 (condition-case nil |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
134 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix nil t) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
135 (text-conversion-error |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
136 (setq text-conversion-error-signalled t))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
137 (Assert text-conversion-error-signalled) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
138 (setq text-conversion-error-signalled nil) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
139 (condition-case nil |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
140 (query-coding-region (point-min) (point-max) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
141 'iso-latin-1-with-esc-unix nil t) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
142 (text-conversion-error |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
143 (setq text-conversion-error-signalled t))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
144 (Assert (null text-conversion-error-signalled)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
145 (delete-region (point-min) (point-max)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
146 (insert latin-1-chars-string) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
147 (decode-coding-region (point-min) (point-max) 'windows-1252-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
148 (goto-char (point-max)) ;; #'decode-coding-region just messed up point. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
149 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
150 (query-coding-region (point-min) (point-max) 'windows-1252-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
151 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
152 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
153 (insert ?\x80) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
154 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
155 (query-coding-region (point-min) (point-max) 'windows-1252-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
156 (Assert (null query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
157 (Assert (equal query-coding-table |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
158 #s(range-table type start-closed-end-open data |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
159 ((257 258) t))))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
160 ;; Try a similar approach with koi8-o, the koi8 variant with |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
161 ;; support for Old Church Slavonic. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
162 (delete-region (point-min) (point-max)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
163 (insert latin-1-chars-string) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
164 (decode-coding-region (point-min) (point-max) 'koi8-o-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
165 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
166 (query-coding-region (point-min) (point-max) 'koi8-o-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
167 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
168 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
169 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
170 (query-coding-region (point-min) (point-max) 'escape-quoted) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
171 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
172 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
173 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
174 (query-coding-region (point-min) (point-max) 'windows-1252-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
175 (Assert (null query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
176 (Assert (equal query-coding-table |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
177 #s(range-table type start-closed-end-open |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
178 data ((129 131) t (132 133) t (139 140) t |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
179 (141 146) t (155 156) t (157 161) t |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
180 (162 170) t (173 176) t (178 187) t |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
181 (189 192) t (193 257) t))))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
182 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
183 (query-coding-region (point-min) (point-max) 'koi8-r-unix) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
184 (Assert (null query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
185 (Assert (equal query-coding-table |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
186 #s(range-table type start-closed-end-open |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
187 data ((129 154) t (155 161) t (162 164) t |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
188 (165 177) t (178 180) t |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
189 (181 192) t))))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
190 ;; Check that the Unicode coding systems handle characters |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
191 ;; without Unicode mappings. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
192 (delete-region (point-min) (point-max)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
193 (insert latin-1-chars-string) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
194 (decode-coding-region (point-min) (point-max) 'greek-iso-8bit-with-esc) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
195 (dolist (coding-system |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
196 '(utf-16-mac ucs-4-mac utf-16-little-endian-bom-dos ucs-4-dos |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
197 utf-16-little-endian-mac utf-16-bom-unix |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
198 utf-16-little-endian ucs-4 utf-16-dos |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
199 ucs-4-little-endian-dos utf-16-bom-mac utf-16-bom |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
200 utf-16-unix utf-32-unix utf-32-little-endian |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
201 utf-32-dos utf-32 utf-32-little-endian-dos utf-8-bom |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
202 utf-16-bom-dos ucs-4-unix |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
203 utf-16-little-endian-bom-unix utf-8-bom-mac |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
204 utf-32-little-endian-unix utf-16 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
205 utf-16-little-endian-dos utf-16-little-endian-bom-mac |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
206 utf-8-bom-dos ucs-4-little-endian-mac utf-8-bom-unix |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
207 utf-32-little-endian-mac utf-8-dos utf-8-unix |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
208 utf-32-mac utf-8-mac utf-16-little-endian-unix |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
209 ucs-4-little-endian ucs-4-little-endian-unix utf-8 |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
210 utf-16-little-endian-bom)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
211 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
212 (query-coding-region (point-min) (point-max) coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
213 (Assert (null query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
214 (Assert (equal query-coding-table |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
215 #s(range-table type start-closed-end-open data |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
216 ((173 174) t (209 210) t |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
217 (254 255) t))))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
218 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
219 (query-coding-region (point-min) 173 coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
220 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
221 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
222 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
223 (query-coding-region 174 209 coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
224 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
225 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
226 (multiple-value-bind (query-coding-succeeded query-coding-table) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
227 (query-coding-region 210 254 coding-system) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
228 (Assert (eq t query-coding-succeeded)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
229 (Assert (null query-coding-table))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
230 ;; Check that it errors correctly. |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
231 (setq text-conversion-error-signalled nil) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
232 (condition-case nil |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
233 (query-coding-region (point-min) (point-max) coding-system nil t) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
234 (text-conversion-error |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
235 (setq text-conversion-error-signalled t))) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
236 (Assert text-conversion-error-signalled) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
237 (setq text-conversion-error-signalled nil) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
238 (condition-case nil |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
239 (query-coding-region (point-min) 173 coding-system nil t) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
240 (text-conversion-error |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff
changeset
|
241 (setq text-conversion-error-signalled t))) |
4570
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
242 (Assert (null text-conversion-error-signalled))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
243 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
244 ;; Now to test #'encode-coding-char. Most of the functionality was |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
245 ;; tested in the query-coding-region tests above, so we don't go into |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
246 ;; as much detail here. |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
247 (Assert (null (encode-coding-char |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
248 (decode-char 'ucs #x20ac) 'iso-8859-1))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
249 (Assert (equal "\x80" (encode-coding-char |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
250 (decode-char 'ucs #x20ac) 'windows-1252))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
251 (delete-region (point-min) (point-max)) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
252 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
253 ;; And #'unencodable-char-position. |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
254 (insert latin-1-chars-string) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
255 (insert (decode-char 'ucs #x20ac)) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
256 (Assert (= 257 (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
257 'iso-8859-1))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
258 (Assert (equal '(257) (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
259 'iso-8859-1 1))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
260 ;; Compatiblity, sigh: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
261 (Assert (equal '(257) (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
262 'iso-8859-1 0))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
263 (dotimes (i 6) (insert (decode-char 'ucs #x20ac))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
264 ;; Check if it stops at one: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
265 (Assert (equal '(257) (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
266 'iso-8859-1 1))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
267 ;; Check if it stops at four: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
268 (Assert (equal '(260 259 258 257) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
269 (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
270 'iso-8859-1 4))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
271 ;; Check whether it stops at seven: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
272 (Assert (equal '(263 262 261 260 259 258 257) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
273 (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
274 'iso-8859-1 7))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
275 ;; Check that it still stops at seven: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
276 (Assert (equal '(263 262 261 260 259 258 257) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
277 (unencodable-char-position (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
278 'iso-8859-1 2000))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
279 ;; Now, #'check-coding-systems-region. |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
280 ;; UTF-8 should certainly be able to encode these characters: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
281 (Assert (eq t (check-coding-systems-region (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
282 '(utf-8)))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
283 (Assert (equal '((iso-8859-1 257 258 259 260 261 262 263) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
284 (windows-1252 129 131 132 133 134 135 136 137 138 139 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
285 140 141 143 146 147 148 149 150 151 152 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
286 153 154 155 156 157 159 160)) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
287 (sort |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
288 (check-coding-systems-region (point-min) (point-max) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
289 '(utf-8 iso-8859-1 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
290 windows-1252)) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
291 ;; (The sort is to make the algorithm irrelevant.) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
292 #'(lambda (left right) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
293 (string< (car left) (car right)))))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
294 ;; Ensure that the indices are all decreased by one when passed a |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
295 ;; string: |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
296 (Assert (equal '((iso-8859-1 256 257 258 259 260 261 262) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
297 (windows-1252 128 130 131 132 133 134 135 136 137 138 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
298 139 140 142 145 146 147 148 149 150 151 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
299 152 153 154 155 156 158 159)) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
300 (sort |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
301 (check-coding-systems-region (buffer-string) nil |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
302 '(utf-8 iso-8859-1 |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
303 windows-1252)) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
304 #'(lambda (left right) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
305 (string< (car left) (car right))))))))) |
e6a7054a9c30
Add check-coding-systems-region, test it and others, fix some bugs.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
306 |