name-char.lsp 3.06 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9 10 11
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Aug 29 17:14:03 2004
;;;; Contains: Tests of NAME-CHAR

(in-package :cl-test)

(compile-and-load "char-aux.lsp")

(deftest name-char.1
  (name-char.1.body)
12
  ())
pfdietz's avatar
pfdietz committed
13 14 15

(deftest name-char.2
  (loop for s in '("RubOut" "PAGe" "BacKspace" "RetUrn" "Tab" "LineFeed"
sds's avatar
sds committed
16
                   "SpaCE" "NewLine")
17
        unless
sds's avatar
sds committed
18 19 20 21
        (let ((c1 (name-char (string-upcase s)))
              (c2 (name-char (string-downcase s)))
              (c3 (name-char (string-capitalize s)))
              (c4 (name-char s)))
22 23 24
          (and (eqlt c1 c2) (eqlt c2 c3) (eqlt c3 c4)))
        collect s)
  ())
pfdietz's avatar
pfdietz committed
25 26 27 28 29 30 31 32 33 34 35 36

(deftest name-char.order.1
  (let ((i 0))
    (values
     (name-char (progn (incf i) "Space"))
     i))
  #\Space 1)

;;; Specialized sequence tests

(deftest name-char.specialized.1
  (loop for etype in '(standard-char base-char character)
sds's avatar
sds committed
37 38 39 40 41 42 43
        append
        (loop for s in '("Rubout" "Page" "Backspace" "Return" "Tab" "Linefeed"
                         "Space" "Newline")
              for s2 = (make-array (length s) :element-type 'base-char
                                   :initial-contents s)
              unless (eql (name-char s) (name-char s2))
              collect (list s s2)))
pfdietz's avatar
pfdietz committed
44 45 46 47
  nil)

(deftest name-char.specialized.2
  (loop for etype in '(standard-char base-char character)
sds's avatar
sds committed
48 49 50 51 52 53 54 55
        append
        (loop for s in '("Rubout" "Page" "Backspace" "Return" "Tab" "Linefeed"
                         "Space" "Newline")
              for s2 = (make-array (length s) :element-type etype
                                   :adjustable t
                                   :initial-contents s)
              unless (eql (name-char s) (name-char s2))
              collect (list etype s s2)))
pfdietz's avatar
pfdietz committed
56 57 58 59
  nil)

(deftest name-char.specialized.3
  (loop for etype in '(standard-char base-char character)
sds's avatar
sds committed
60 61 62 63 64 65 66 67
        append
        (loop for s in '("Rubout" "Page" "Backspace" "Return" "Tab" "Linefeed"
                         "Space" "Newline")
              for s2 = (make-array (+ 3 (length s)) :element-type etype
                                   :fill-pointer (length s)
                                   :initial-contents (concatenate 'string s "   "))
              unless (eql (name-char s) (name-char s2))
              collect (list etype s s2)))
pfdietz's avatar
pfdietz committed
68 69 70 71
  nil)

(deftest name-char.specialized.4
  (loop for etype in '(standard-char base-char character)
sds's avatar
sds committed
72 73 74 75 76 77 78 79 80
        append
        (loop for s in '("Rubout" "Page" "Backspace" "Return" "Tab" "Linefeed"
                         "Space" "Newline")
              for s1 = (make-array (+ 4 (length s)) :element-type etype
                                   :initial-contents (concatenate 'string "  " s "  "))
              for s2 = (make-array (length s) :element-type etype
                                   :displaced-to s1 :displaced-index-offset 2)
              unless (eql (name-char s) (name-char s2))
              collect (list etype s s2)))
pfdietz's avatar
pfdietz committed
81 82 83 84 85 86 87 88 89 90 91
  nil)

;;; Error tests

(deftest name-char.error.1
  (signals-error (name-char) program-error)
  t)

(deftest name-char.error.2
  (signals-error (name-char "space" "space") program-error)
  t)