stringp.lsp 2.38 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Aug 29 17:32:20 2004
;;;; Contains: Tests of STRINGP

(in-package :cl-test)

(deftest stringp.1
9 10
  (check-type-predicate #'stringp 'string)
  nil)
pfdietz's avatar
pfdietz committed
11 12 13 14 15 16 17

(deftest stringp.2
  (notnot (stringp "abcd"))
  t)

(deftest stringp.3
  (notnot (stringp (make-array 4 :element-type 'character
sds's avatar
sds committed
18
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
19 20 21 22
  t)

(deftest stringp.4
  (notnot (stringp (make-array 4 :element-type 'base-char
sds's avatar
sds committed
23
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
24 25 26 27
  t)

(deftest stringp.5
  (notnot (stringp (make-array 4 :element-type 'standard-char
sds's avatar
sds committed
28
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
29 30 31 32 33 34 35 36 37 38 39 40
  t)

(deftest stringp.6
  (stringp 0)
  nil)

(deftest stringp.7
  (stringp #\a)
  nil)

(deftest stringp.8
  (let* ((s (make-array 10 :element-type 'character
sds's avatar
sds committed
41 42 43 44
                        :initial-element #\a))
         (s2 (make-array 4 :element-type 'character
                         :displaced-to s
                         :displaced-index-offset 2)))
pfdietz's avatar
pfdietz committed
45 46 47 48 49 50 51 52 53 54 55 56
    (notnot (stringp s2)))
  t)

(deftest stringp.9
  :notes (:nil-vectors-are-strings)
  (notnot-mv (stringp (make-array '(0) :element-type nil)))
  t)

(deftest stringp.10
  :notes (:nil-vectors-are-strings)
  (notnot-mv (stringp (make-array '(37) :element-type nil)))
  t)
pfdietz's avatar
pfdietz committed
57 58 59

(deftest stringp.11
  (notnot (stringp (make-array 4 :element-type 'base-char
sds's avatar
sds committed
60 61
                               :fill-pointer 2
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
62 63 64 65
  t)

(deftest stringp.12
  (notnot (stringp (make-array 4 :element-type 'base-char
sds's avatar
sds committed
66 67
                               :adjustable t
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
68 69 70 71
  t)

(deftest stringp.13
  (notnot (stringp (make-array 4 :element-type 'character
sds's avatar
sds committed
72 73
                               :fill-pointer 2
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
74 75 76 77
  t)

(deftest stringp.14
  (notnot (stringp (make-array 4 :element-type 'character
sds's avatar
sds committed
78 79
                               :adjustable t
                               :initial-contents '(#\a #\b #\c #\d))))
pfdietz's avatar
pfdietz committed
80 81
  t)

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
(deftest stringp.15
  (let ((i 0))
    (values
     (notnot (stringp (progn (incf i) "")))
     i))
  t 1)

;;; Error tests

(deftest stringp.error.1
  (signals-error (stringp) program-error)
  t)

(deftest stringp.error.2
  (signals-error (stringp "" nil) program-error)
  t)