annotate tests/automated/query-coding-tests.el @ 4568:1d74a1d115ee

Add #'query-coding-region tests; do the work necessary to get them running. lisp/ChangeLog addition: 2008-12-28 Aidan Kehoe <kehoea@parhasard.net> * coding.el (default-query-coding-region): Declare using defun*, so we can #'return-from to it on encountering a safe-charsets value of t. Comment out a few debug messages. (query-coding-region): Correct the docstring, it deals with a region, not a string. (unencodable-char-position): Correct the implementation for non-nil COUNT, special-case a zero value for count, treat it as one. Don't rely on dynamic scope when calling the main lambda. * unicode.el (unicode-query-coding-region): Comment out some debug messages here. * mule/mule-coding.el (8-bit-fixed-query-coding-region): Comment out some debug messages here. * code-init.el (raw-text): Add a safe-charsets property to this coding system. * mule/korean.el (iso-2022-int-1): * mule/korean.el (euc-kr): * mule/korean.el (iso-2022-kr): Add safe-charsets properties for these coding systems. * mule/japanese.el (iso-2022-jp): * mule/japanese.el (jis7): * mule/japanese.el (jis8): * mule/japanese.el (shift-jis): * mule/japanese.el (iso-2022-jp-1978-irv): * mule/japanese.el (euc-jp): Add safe-charsets properties for all these coding systems. * mule/iso-with-esc.el: Add safe-charsets properties to all the coding systems in here. Comment on the downside of a safe-charsets value of t for iso-latin-1-with-esc. * mule/hebrew.el (ctext-hebrew): Add a safe-charsets property for this coding system. * mule/devanagari.el (in-is13194-devanagari): Add a safe-charsets property for this coding system. * mule/chinese.el (cn-gb-2312): * mule/chinese.el (hz-gb-2312): * mule/chinese.el (big5): Add safe-charsets properties for these coding systems. * mule/latin.el (iso-8859-14): Add an implementation for this, using #'make-8-bit-coding-system. * mule/mule-coding.el (ctext): * mule/mule-coding.el (iso-2022-8bit-ss2): * mule/mule-coding.el (iso-2022-7bit-ss2): * mule/mule-coding.el (iso-2022-jp-2): * mule/mule-coding.el (iso-2022-7bit): * mule/mule-coding.el (iso-2022-8): * mule/mule-coding.el (escape-quoted): * mule/mule-coding.el (iso-2022-lock): Add safe-charsets properties for all these coding systems. src/ChangeLog addition: 2008-12-28 Aidan Kehoe <kehoea@parhasard.net> * file-coding.c (Fmake_coding_system): Document our use of the safe-chars and safe-charsets properties, and the differences compared to GNU. (make_coding_system_1): Don't drop the safe-chars and safe-charsets properties. (Fcoding_system_property): Return the safe-chars and safe-charsets properties when asked for them. * file-coding.h (CODING_SYSTEM_SAFE_CHARSETS): * coding-system-slots.h: Make the safe-chars and safe-charsets slots available in these headers. tests/ChangeLog addition: 2008-12-28 Aidan Kehoe <kehoea@parhasard.net> * automated/query-coding-tests.el: New file, testing the functionality of #'query-coding-region and #'query-coding-string.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 28 Dec 2008 14:46:24 +0000
parents
children e6a7054a9c30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 (q-c-debug "checking type, coding-system, q-c-s, q-c-t %S"
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
95 (list (coding-system-type coding-system)
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
96 coding-system 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
97 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
98 (unless (and (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 (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 (q-c-debug "(eq t query-coding-succeeded) %S, (\
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
101 null query-coding-table) %S" (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
102 (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
103 (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
104 (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
105 (q-c-debug "testing the ASCII strings for %S" coding-system)
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
106 (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
107 (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
108 (unless (and (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
109 (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
110 (q-c-debug "(eq t query-coding-succeeded) %S, (\
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
111 null query-coding-table) %S" (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
112 (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
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 (q-c-debug "past the loop through the coding systems")
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
116 (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
117 ;; 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
118 (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
119 (q-c-debug "point is now %S" (point))
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
120 (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
121 (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
122 (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
123 (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
124 (q-c-debug "point is now %S" (point))
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
125 (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
126 (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
127 (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
128 (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
129 (q-c-debug "point is now %S" (point))
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
130 (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
131 (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
132 (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
133 (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
134 (q-c-debug "point is now %S" (point))
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
135 ;; 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
136 (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
137 (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
138 (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
139 (unless (and (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
140 (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
141 #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
142 ((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
143 (q-c-debug "dealing with %S" '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
144 (q-c-debug "query-coding-succeeded not 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
145 %S" 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
146 (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
147 (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
148 #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
149 ((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
150 (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
151 (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
152 '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
153 ;; 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
154 ;; 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
155 ;; 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
156
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
157 (unless (and 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
158 (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
159 (q-c-debug "dealing with %S" '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
160 (q-c-debug "query-coding-succeeded %S, 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
161 %S" 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
162 (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
163 (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
164 ;; 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
165 (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
166 (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
167 (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
168 (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
169 (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
170 (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
171 (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
172 (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
173 (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
174 '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
175 (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
176 (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
177 (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
178 (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
179 (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
180 (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
181 (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
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) '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
184 (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
185 (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
186 (insert ?\x80)
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
187 (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
188 (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
189 (unless (and (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
190 (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
191 #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
192 ((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
193 (q-c-debug "dealing with %S" '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
194 (q-c-debug "query-coding-succeeded not 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
195 %S" 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
196 (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
197 (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
198 #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
199 ((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
200 ;; 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
201 ;; 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
202 (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
203 (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
204 (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
205 (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
206 (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
207 (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
208 (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
209 (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
210 (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
211 (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
212 (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
213 (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
214 (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
215 (unless (and (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
216 (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
217 #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
218 data ((129 131) t (132 133) t
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
219 (139 140) t (141 146) t
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
220 (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
221 (162 170) t (173 176) t
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
222 (178 187) t (189 192) t
1d74a1d115ee Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
223 (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
224 (q-c-debug "query-coding-succeeded not 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
225 %S" 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 (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
227 (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
228 #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
229 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
230 (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
231 (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
232 (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
233 (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
234 (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
235 (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
236 (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
237 #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
238 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
239 (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
240 (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
241 ;; 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
242 ;; 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
243 (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
244 (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
245 (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
246 (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
247 '(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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 (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
263 (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
264 (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
265 (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
266 #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
267 ((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
268 (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
269 (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
270 (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
271 (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
272 (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
273 (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
274 (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
275 (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
276 (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
277 (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
278 (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
279 (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
280 (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
281 ;; 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
282 (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
283 (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
284 (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
285 (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
286 (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
287 (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
288 (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
289 (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
290 (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
291 (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
292 (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
293 (Assert (null text-conversion-error-signalled))))))