1 (defvar *str* "hello world")
5 (test (not (characterp *str*)))
6 (test (not (integerp *str*)))
8 (test (stringp *str2*))
9 (test (not (characterp *str2*)))
10 (test (not (integerp *str2*)))
12 (test (= (length "hello world") 11))
13 (test (arrayp "hello world"))
15 (test (string= "h" (string #\h)))
16 (test (string= "foo" "foo"))
17 (test (not (string= "Foo" "foo")))
18 (test (not (string= "foo" "foox")))
20 (test (= (string< "one" "two") 0))
21 (test (= (string< "oob" "ooc") 2))
22 (test (null (string< "" "")))
23 (test (null (string< "a" "")))
24 (test (= (string< "" "a") 0))
25 (test (= (string< "aaa" "aaaaa") 3))
27 ;;; BUG: The compiler will macroexpand the forms below (char str N)
28 ;;; will expand to internal SBCL code instead of our (setf char). It
29 ;;; is because macrodefinitions during bootstrapping are not included
30 ;;; in the host's environment. It should, but we have to think how to
31 ;;; avoid conflicts (package renaming??)
33 ;; (let ((str "hello"))
34 ;; (setf (char str 0) #\X)
35 ;; (setf (char str 4) #\X)
36 ;; (test (string= str "XellX")))
38 ;; ----------------------------------------
39 ;; The following tests in this file were derived from the file "must-string.lisp",
40 ;; part of SACLA <http://homepage1.nifty.com/bmonkey/lisp/sacla/>.
41 ;; The origial copyright notice appears below:
43 ;; Copyright (C) 2002-2004, Yuji Minejima <ggb01164@nifty.ne.jp>
44 ;; ALL RIGHTS RESERVED.
46 ;; $Id: must-string.lisp,v 1.7 2004/02/20 07:23:42 yuji Exp $
48 ;; Redistribution and use in source and binary forms, with or without
49 ;; modification, are permitted provided that the following conditions
52 ;; * Redistributions of source code must retain the above copyright
53 ;; notice, this list of conditions and the following disclaimer.
54 ;; * Redistributions in binary form must reproduce the above copyright
55 ;; notice, this list of conditions and the following disclaimer in
56 ;; the documentation and/or other materials provided with the
59 ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
60 ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
61 ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
62 ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
63 ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64 ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
65 ;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
66 ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
67 ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
68 ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
69 ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71 ;; JSCL: no SIMPLE-STRING-P yet, so disabled
72 ;; (test (simple-string-p ""))
73 ;; (test (simple-string-p "abc"))
74 ;; (test (not (simple-string-p 'not-a-string)))
75 ;; (test (let ((str (make-array 3 :element-type 'character :fill-pointer t)))
76 ;; (if (not (simple-vector-p str))
77 ;; (not (simple-string-p str))
78 ;; (simple-string-p str))))
80 (test (char= (char "abc" 0) #\a))
81 (test (char= (char "abc" 1) #\b))
82 (test (char= (char "abc" 2) #\c))
83 ;; JSCL: no SCHAR yet, so disabled
84 ;; (test (char= (schar "abc" 0) #\a))
85 ;; (test (char= (schar "abc" 1) #\b))
86 ;; (test (char= (schar "abc" 2) #\c))
87 ;; JSCL: no :FILL-POINTER yet, so disabled
88 ;; (test (let ((str (make-array 10
89 ;; :element-type 'character
91 ;; :initial-contents "0123456789")))
92 ;; (and (string= str "012")
93 ;; (char= (char str 3) #\3)
94 ;; (char= (char str 4) #\4)
95 ;; (char= (char str 5) #\5)
96 ;; (char= (char str 6) #\6)
97 ;; (char= (char str 7) #\7)
98 ;; (char= (char str 8) #\8)
99 ;; (char= (char str 9) #\9)
100 ;; (char= (vector-pop str) #\2))))
102 (test (string= (string "") ""))
103 (test (string= (string "abc") "abc"))
104 (test (string= (string "a") "a"))
105 (test (string= (string 'abc) "ABC"))
106 (test (string= (string 'a) "A"))
107 (test (string= (string #\a) "a"))
110 (test (string= (string-upcase "abcde") "ABCDE"))
111 (test (string= (string-upcase "Dr. Livingston, I presume?")
112 "DR. LIVINGSTON, I PRESUME?"))
113 (test (string= (string-upcase "Dr. Livingston, I presume?" :start 6 :end 10)
114 "Dr. LiVINGston, I presume?"))
115 (test (string= (string-upcase 'Kludgy-HASH-Search) "KLUDGY-HASH-SEARCH"))
116 (test (string= (string-upcase "abcde" :start 2 :end nil) "abCDE"))
118 (test (string= (string-downcase "Dr. Livingston, I presume?")
119 "dr. livingston, i presume?"))
120 (test (string= (string-downcase 'Kludgy-HASH-Search) "kludgy-hash-search"))
121 (test (string= (string-downcase "A FOOL" :start 2 :end nil) "A fool"))
122 (test (string= (string-capitalize "elm 13c arthur;fig don't")
123 "Elm 13c Arthur;Fig Don'T"))
124 (test (string= (string-capitalize " hello ") " Hello "))
125 (test (string= (string-capitalize
126 "occlUDeD cASEmenTs FOreSTAll iNADVertent DEFenestraTION")
127 "Occluded Casements Forestall Inadvertent Defenestration"))
128 (test (string= (string-capitalize 'kludgy-hash-search) "Kludgy-Hash-Search"))
129 (test (string= (string-capitalize "DON'T!") "Don'T!")) ;not "Don't!"
130 (test (string= (string-capitalize "pipe 13a, foo16c") "Pipe 13a, Foo16c"))
131 (test (string= (string-capitalize "a fool" :start 2 :end nil) "a Fool"))
133 ;; JSCL HACK: a simple COPY-SEQ for testing string functions, since we don't have a real one yet -- remove me
134 (defun copy-seq (string)
135 (let ((copy (make-string (length string))))
136 (dotimes (i (length string) copy)
137 (aset copy i (char string i)))))
139 (test (let ((str (copy-seq "0123ABCD890a")))
140 (and (string= (nstring-downcase str :start 5 :end 7) "0123AbcD890a")
141 (string= str "0123AbcD890a"))))
143 (test (let* ((str0 (copy-seq "abcde"))
144 (str (nstring-upcase str0)))
146 (string= str "ABCDE"))))
147 (test (let* ((str0 (copy-seq "Dr. Livingston, I presume?"))
148 (str (nstring-upcase str0)))
150 (string= str "DR. LIVINGSTON, I PRESUME?"))))
151 (test (let* ((str0 (copy-seq "Dr. Livingston, I presume?"))
152 (str (nstring-upcase str0 :start 6 :end 10)))
154 (string= str "Dr. LiVINGston, I presume?"))))
156 (test (let* ((str0 (copy-seq "abcde"))
157 (str (nstring-upcase str0 :start 2 :end nil)))
158 (string= str "abCDE")))
162 (test (let* ((str0 (copy-seq "Dr. Livingston, I presume?"))
163 (str (nstring-downcase str0)))
165 (string= str "dr. livingston, i presume?"))))
166 (test (let* ((str0 (copy-seq "ABCDE"))
167 (str (nstring-downcase str0 :start 2 :end nil)))
168 (string= str "ABcde")))
170 (test (let* ((str0 (copy-seq "elm 13c arthur;fig don't"))
171 (str (nstring-capitalize str0)))
173 (string= str "Elm 13c Arthur;Fig Don'T"))))
175 (test (let* ((str0 (copy-seq " hello "))
176 (str (nstring-capitalize str0)))
178 (string= str " Hello "))))
179 (test (let* ((str0 (copy-seq
180 "occlUDeD cASEmenTs FOreSTAll iNADVertent DEFenestraTION"))
181 (str (nstring-capitalize str0)))
184 "Occluded Casements Forestall Inadvertent Defenestration"))))
185 (test (let* ((str0 (copy-seq "DON'T!"))
186 (str (nstring-capitalize str0)))
188 (string= str "Don'T!")))) ;not "Don't!"
189 (test (let* ((str0 (copy-seq "pipe 13a, foo16c"))
190 (str (nstring-capitalize str0)))
192 (string= str "Pipe 13a, Foo16c"))))
193 (test (let* ((str0 (copy-seq "a fool"))
194 (str (nstring-capitalize str0 :start 2 :end nil)))
195 (string= str "a Fool")))
199 (test (string= (string-trim "abc" "abcaakaaakabcaaa") "kaaak"))
200 ;; (test (string= (string-trim '(#\Space #\Tab #\Newline) " garbanzo beans
201 ;; ") "garbanzo beans"))
202 (test (string= (string-trim " (*)" " ( *three (silly) words* ) ")
203 "three (silly) words"))
204 (test (string= (string-left-trim "abc" "labcabcabc") "labcabcabc"))
205 (test (string= (string-left-trim " (*)" " ( *three (silly) words* ) ")
206 "three (silly) words* ) "))
207 (test (string= (string-right-trim " (*)" " ( *three (silly) words* ) ")
208 " ( *three (silly) words"))
209 (test (string= (string-trim "ABC" "abc") "abc"))
210 (test (string= (string-trim "AABBCC" "abc") "abc"))
211 (test (string= (string-trim "" "abc") "abc"))
212 (test (string= (string-trim "ABC" "") ""))
213 (test (string= (string-trim "cba" "abc") ""))
214 (test (string= (string-trim "cba" "abccba") ""))
215 (test (string= (string-trim "ccbbba" "abccba") ""))
216 (test (string= (string-trim "cba" "abcxabc") "x"))
217 (test (string= (string-trim "xyz" "xxyabcxyyz") "abc"))
218 (test (string= (string-trim "CBA" 'abcxabc) "X"))
219 (test (string= (string-trim "a" #\a) ""))
222 (test (string= (string-left-trim "ABC" "abc") "abc"))
223 (test (string= (string-left-trim "" "abc") "abc"))
224 (test (string= (string-left-trim "ABC" "") ""))
225 (test (string= (string-left-trim "cba" "abc") ""))
226 (test (string= (string-left-trim "cba" "abccba") ""))
227 (test (string= (string-left-trim "cba" "abcxabc") "xabc"))
228 (test (string= (string-left-trim "xyz" "xxyabcxyz") "abcxyz"))
229 (test (string= (string-left-trim "CBA" 'abcxabc) "XABC"))
230 (test (string= (string-left-trim "a" #\a) ""))
232 (test (string= (string-right-trim "ABC" "abc") "abc"))
233 (test (string= (string-right-trim "" "abc") "abc"))
234 (test (string= (string-right-trim "ABC" "") ""))
235 (test (string= (string-right-trim "cba" "abc") ""))
236 (test (string= (string-right-trim "cba" "abccba") ""))
237 (test (string= (string-right-trim "cba" "abcxabc") "abcx"))
238 (test (string= (string-right-trim "xyz" "xxyabcxyz") "xxyabc"))
239 (test (string= (string-right-trim "CBA" 'abcxabc) "ABCX"))
240 (test (string= (string-right-trim "a" #\a) ""))
244 (test (string= (string "already a string") "already a string"))
245 (test (string= (string 'elm) "ELM"))
246 (test (string= (string #\c) "c"))
249 (test (string= "foo" "foo"))
250 (test (not (string= "foo" "Foo")))
251 (test (not (string= "foo" "bar")))
252 (test (string= "together" "frog" :start1 1 :end1 3 :start2 2))
253 (test (string-equal "foo" "Foo"))
254 (test (string= "abcd" "01234abcd9012" :start2 5 :end2 9))
255 (test (eql (string< "aaaa" "aaab") 3))
256 (test (eql (string>= "aaaaa" "aaaa") 4))
257 (test (eql (string-not-greaterp "Abcde" "abcdE") 5))
258 (test (eql (string-lessp "012AAAA789" "01aaab6"
260 :start2 2 :end2 6) 6))
261 (test (not (string-not-equal "AAAA" "aaaA")))
264 (test (string= "" ""))
265 ;; JSCL: making an array of BASE-CHAR doesn't make a string, yet
266 ;; (test (string= (make-array 0 :element-type 'character)
267 ;; (make-array 0 :element-type 'base-char)))
268 (test (not (string= "abc" "")))
269 (test (not (string= "" "abc")))
270 (test (not (string= "A" "a")))
271 (test (string= "abc" "xyz" :start1 3 :start2 3))
272 (test (string= "abc" "xyz" :start1 1 :end1 1 :start2 0 :end2 0))
273 (test (string= "axyza" "xyz" :start1 1 :end1 4))
274 (test (string= "axyza" "xyz" :start1 1 :end1 4 :start2 0 :end2 nil))
275 (test (string= "abxyz" "xyabz" :end1 2 :start2 2 :end2 4))
276 (test (not (string= "love" "hate")))
277 (test (string= 'love 'love))
278 (test (not (string= 'love "hate")))
279 (test (string= #\a #\a))
282 (test (not (string/= "" "")))
283 ;; (test (not (string/= (make-array 0 :element-type 'character)
284 ;; (make-array 0 :element-type 'base-char))))
285 (test (eql (string/= "abc" "") 0))
286 (test (eql (string/= "" "abc") 0))
287 (test (eql (string/= "A" "a") 0))
288 (test (not (string/= "abc" "xyz" :start1 3 :start2 3)))
289 (test (not (string/= "abc" "xyz" :start1 1 :end1 1 :start2 0 :end2 0)))
290 (test (not (string/= "axyza" "xyz" :start1 1 :end1 4)))
291 (test (not (string/= "axyza" "xyz" :start1 1 :end1 4 :start2 0 :end2 nil)))
292 (test (not (string/= "abxyz" "xyabz" :end1 2 :start2 2 :end2 4)))
293 (test (eql (string/= "love" "hate") 0))
294 (test (eql (string/= "love" "loVe") 2))
295 (test (not (string/= "life" "death" :start1 3 :start2 1 :end2 2)))
296 (test (eql (string/= "abcxyz" "ABCxyZ" :start1 3 :start2 3) 5))
297 (test (eql (string/= "abcxyz" "ABCxyZ" :start1 3 :end1 nil :start2 3 :end2 nil) 5))
298 (test (eql (string/= "abcxyz" "ABCxyZ" :end1 nil :start2 3 :end2 3) 0))
299 (test (eql (string/= "abc" "abcxyz") 3))
300 (test (eql (string/= "abcxyz" "abc") 3))
301 (test (eql (string/= "abcxyz" "") 0))
302 (test (eql (string/= "AbcDef" "cdef" :start1 2) 3))
303 (test (eql (string/= "cdef" "AbcDef" :start2 2) 1))
304 (test (= (string/= 'love "hate") 0))
305 (test (not (string/= 'love 'love)))
306 (test (not (string/= #\a #\a)))
307 (test (= (string/= #\a #\b) 0))
309 (test (not (string< "" "")))
310 (test (not (string< "dog" "dog")))
311 (test (not (string< " " " ")))
312 (test (not (string< "abc" "")))
313 (test (eql (string< "" "abc") 0))
314 (test (eql (string< "ab" "abc") 2))
315 (test (not (string< "abc" "ab")))
316 (test (eql (string< "aaa" "aba") 1))
317 (test (not (string< "aba" "aaa")))
318 (test (not (string< "my cat food" "your dog food" :start1 6 :start2 8)))
319 (test (not (string< "cat food 2 dollars" "dog food 3 dollars"
320 :start1 3 :end1 9 :start2 3 :end2 9)))
321 (test (eql (string< "xyzabc" "abcd" :start1 3) 6))
322 (test (eql (string< "abc" "abc" :end1 1) 1))
323 (test (eql (string< "xyzabc" "abc" :start1 3 :end1 5) 5))
324 (test (eql (string< "xyz" "abcxyzXYZ" :start2 3) 3))
325 (test (not (string< "abc" "abcxyz" :end2 3)))
326 (test (eql (string< "xyz" "abcxyz" :end1 2 :start2 3) 2))
327 (test (not (string< "xyzabc" "abcdef" :start1 3 :end2 3)))
328 (test (eql (string< "aaaa" "z") 0))
329 (test (eql (string< "pppTTTaTTTqqq" "pTTTxTTT" :start1 3 :start2 1) 6))
330 (test (eql (string< "pppTTTaTTTqqq" "pTTTxTTT"
332 :start2 4 :end2 5) 6))
333 ;; (test (not (string< (make-array 0 :element-type 'character)
334 ;; (make-array 0 :element-type 'base-char))))
335 (test (not (string< 'love 'hate)))
336 (test (= (string< 'peace 'war) 0))
337 (test (not (string< 'love 'love)))
338 (test (not (string< #\a #\a)))
339 (test (= (string< #\a #\b) 0))
342 (test (not (string> "" "")))
343 (test (not (string> "dog" "dog")))
344 (test (not (string> " " " ")))
345 (test (eql (string> "abc" "") 0))
346 (test (not (string> "" "abc")))
347 (test (not (string> "ab" "abc")))
348 (test (eql (string> "abc" "ab") 2))
349 (test (eql (string> "aba" "aaa") 1))
350 (test (not (string> "aaa" "aba")))
351 (test (not (string> "my cat food" "your dog food" :start1 6 :start2 8)))
352 (test (not (string> "cat food 2 dollars" "dog food 3 dollars"
353 :start1 3 :end1 9 :start2 3 :end2 9)))
354 (test (eql (string> "xyzabcde" "abcd" :start1 3) 7))
355 (test (not (string> "abc" "abc" :end1 1)))
356 (test (eql (string> "xyzabc" "a" :start1 3 :end1 5) 4))
357 (test (eql (string> "xyzXYZ" "abcxyz" :start2 3) 3))
358 (test (eql (string> "abcxyz" "abcxyz" :end2 3) 3))
359 (test (not (string> "xyzXYZ" "abcxyz" :end1 2 :start2 3)))
360 (test (not (string> "xyzabc" "abcdef" :start1 3 :end2 3)))
361 (test (eql (string> "z" "aaaa") 0))
362 (test (eql (string> "pTTTxTTTqqq" "pppTTTaTTT" :start1 1 :start2 3) 4))
363 (test (eql (string> "pppTTTxTTTqqq" "pTTTaTTT"
365 :start2 4 :end2 5) 6))
366 ;; (test (not (string> (make-array 0 :element-type 'character)
367 ;; (make-array 0 :element-type 'base-char))))
368 (test (= (string> 'love 'hate) 0))
369 (test (not (string> 'peace 'war)))
370 (test (not (string> 'love 'love)))
371 (test (not (string> #\a #\a)))
372 (test (not (string> #\a #\b)))
373 (test (= (string> #\z #\a) 0))
376 (test (eql (string<= "" "") 0))
377 (test (eql (string<= "dog" "dog") 3))
378 (test (eql (string<= " " " ") 1))
379 (test (not (string<= "abc" "")))
380 (test (eql (string<= "ab" "abc") 2))
381 (test (eql (string<= "aaa" "aba") 1))
382 (test (not (string<= "aba" "aaa")))
383 (test (eql (string<= "my cat food" "your dog food" :start1 6 :start2 8) 11))
384 (test (eql (string<= "cat food 2 dollars" "dog food 3 dollars"
385 :start1 3 :end1 9 :start2 3 :end2 9) 9))
386 (test (eql (string<= "xyzabc" "abcd" :start1 3) 6))
387 (test (eql (string<= "abc" "abc" :end1 1) 1))
388 (test (eql (string<= "xyzabc" "abc" :start1 3 :end1 5) 5))
389 (test (eql (string<= "xyz" "abcxyzXYZ" :start2 3) 3))
390 (test (eql (string<= "abc" "abcxyz" :end2 3) 3))
391 (test (eql (string<= "xyz" "abcxyz" :end1 2 :start2 3) 2))
392 (test (eql (string<= "xyzabc" "abcdef" :start1 3 :end2 3) 6))
393 (test (eql (string<= "aaaa" "z") 0))
394 (test (eql (string<= "pppTTTaTTTqqq" "pTTTxTTT" :start1 3 :start2 1) 6))
395 (test (eql (string<= "pppTTTaTTTqqq" "pTTTxTTT"
397 :start2 4 :end2 5) 6))
398 ;; (test (eql (string<= (make-array 0 :element-type 'character)
399 ;; (make-array 0 :element-type 'base-char)) 0))
400 (test (not (string<= 'love 'hate)))
401 (test (= (string<= 'peace 'war) 0))
402 (test (= (string<= 'love 'love) 4))
403 (test (= (string<= #\a #\a) 1))
404 (test (= (string<= #\a #\b) 0))
405 (test (not (string<= #\z #\a)))
408 (test (eql (string>= "" "") 0))
409 (test (eql (string>= "dog" "dog") 3))
410 (test (eql (string>= " " " ") 1))
411 (test (eql (string>= "abc" "") 0))
412 (test (not (string>= "" "abc")))
413 (test (not (string>= "ab" "abc")))
414 (test (eql (string>= "abc" "ab") 2))
415 (test (eql (string>= "aba" "aaa") 1))
416 (test (not (string>= "aaa" "aba")))
417 (test (eql (string>= "my cat food" "your dog food" :start1 6 :start2 8) 11))
418 (test (eql (string>= "cat food 2 dollars" "dog food 3 dollars"
419 :start1 3 :end1 9 :start2 3 :end2 9) 9))
420 (test (eql (string>= "xyzabcde" "abcd" :start1 3) 7))
421 (test (not (string>= "abc" "abc" :end1 1)))
422 (test (eql (string>= "xyzabc" "a" :start1 3 :end1 5) 4))
423 (test (eql (string>= "xyzXYZ" "abcxyz" :start2 3) 3))
424 (test (eql (string>= "abcxyz" "abcxyz" :end2 3) 3))
425 (test (not (string>= "xyzXYZ" "abcxyz" :end1 2 :start2 3)))
426 (test (eql (string>= "xyzabc" "abcdef" :start1 3 :end2 3) 6))
427 (test (eql (string>= "z" "aaaa") 0))
428 (test (eql (string>= "pTTTxTTTqqq" "pppTTTaTTT" :start1 1 :start2 3) 4))
429 (test (eql (string>= "pppTTTxTTTqqq" "pTTTaTTT"
431 :start2 4 :end2 5) 6))
432 ;; (test (eql (string>= (make-array 0 :element-type 'character)
433 ;; (make-array 0 :element-type 'base-char)) 0))
434 (test (= (string>= 'love 'hate) 0))
435 (test (not (string>= 'peace 'war)))
436 (test (= (string>= 'love 'love) 4))
437 (test (= (string>= #\a #\a) 1))
438 (test (not (string>= #\a #\b)))
439 (test (= (string>= #\z #\a) 0))
444 (test (string-equal "" ""))
445 ;; (test (string-equal (make-array 0 :element-type 'character)
446 ;; (make-array 0 :element-type 'base-char)))
447 (test (not (string-equal "abc" "")))
448 (test (not (string-equal "" "abc")))
449 (test (string-equal "A" "a"))
450 (test (string-equal "abc" "xyz" :start1 3 :start2 3))
451 (test (string-equal "abc" "xyz" :start1 1 :end1 1 :start2 0 :end2 0))
452 (test (string-equal "axyza" "xyz" :start1 1 :end1 4))
453 (test (string-equal "axyza" "xyz" :start1 1 :end1 4 :start2 0 :end2 nil))
454 (test (string-equal "abxyz" "xyabz" :end1 2 :start2 2 :end2 4))
455 (test (not (string-equal "love" "hate")))
456 (test (string-equal "xyz" "XYZ"))
457 (test (not (string-equal 'love 'hate)))
458 (test (not (string-equal 'peace 'war)))
459 (test (string-equal 'love 'love))
460 (test (string-equal #\a #\a))
461 (test (not (string-equal #\a #\b)))
462 (test (not (string-equal #\z #\a)))
465 (test (not (string-not-equal "" "")))
466 ;; (test (not (string-not-equal (make-array 0 :element-type 'character)
467 ;; (make-array 0 :element-type 'base-char))))
468 (test (eql (string-not-equal "abc" "") 0))
469 (test (eql (string-not-equal "" "abc") 0))
470 (test (not (string-not-equal "A" "a")))
471 (test (not (string-not-equal "abc" "xyz" :start1 3 :start2 3)))
472 (test (not (string-not-equal "abc" "xyz" :start1 1 :end1 1 :start2 0 :end2 0)))
473 (test (not (string-not-equal "axyza" "xyz" :start1 1 :end1 4)))
474 (test (not (string-not-equal "axyza" "xyz" :start1 1 :end1 4 :start2 0 :end2 nil)))
475 (test (not (string-not-equal "abxyz" "xyabz" :end1 2 :start2 2 :end2 4)))
476 (test (eql (string-not-equal "love" "hate") 0))
477 (test (not (string-not-equal "love" "loVe")))
478 (test (not (string-not-equal "life" "death" :start1 3 :start2 1 :end2 2)))
479 (test (not (string-not-equal "abcxyz" "ABCxyZ" :start1 3 :start2 3)))
480 (test (not (string-not-equal "abcxyz" "ABCxyZ" :start1 3 :end1 nil :start2 3 :end2 nil)))
481 (test (eql (string-not-equal "abcxyz" "ABCxyZ" :end1 nil :start2 3 :end2 3) 0))
482 (test (eql (string-not-equal "abc" "abcxyz") 3))
483 (test (eql (string-not-equal "abcxyz" "abc") 3))
484 (test (eql (string-not-equal "abcxyz" "") 0))
485 (test (not (string-not-equal "AbcDef" "cdef" :start1 2)))
486 (test (not (string-not-equal "cdef" "AbcDef" :start2 2)))
487 (test (not (string-not-equal "ABC" "abc")))
488 (test (= (string-not-equal 'love 'hate) 0))
489 (test (= (string-not-equal 'peace 'war) 0))
490 (test (not (string-not-equal 'love 'love)))
491 (test (not (string-not-equal #\a #\a)))
492 (test (= (string-not-equal #\a #\b) 0))
493 (test (= (string-not-equal #\z #\a) 0))
496 (test (not (string-lessp "" "")))
497 (test (not (string-lessp "dog" "dog")))
498 (test (not (string-lessp " " " ")))
499 (test (not (string-lessp "abc" "")))
500 (test (eql (string-lessp "" "abc") 0))
501 (test (eql (string-lessp "ab" "abc") 2))
502 (test (not (string-lessp "abc" "ab")))
503 (test (eql (string-lessp "aaa" "aba") 1))
504 (test (not (string-lessp "aba" "aaa")))
505 (test (not (string-lessp "my cat food" "your dog food" :start1 6 :start2 8)))
506 (test (not (string-lessp "cat food 2 dollars" "dog food 3 dollars"
507 :start1 3 :end1 9 :start2 3 :end2 9)))
508 (test (eql (string-lessp "xyzabc" "abcd" :start1 3) 6))
509 (test (eql (string-lessp "abc" "abc" :end1 1) 1))
510 (test (eql (string-lessp "xyzabc" "abc" :start1 3 :end1 5) 5))
511 (test (eql (string-lessp "xyz" "abcxyzXYZ" :start2 3) 3))
512 (test (not (string-lessp "abc" "abcxyz" :end2 3)))
513 (test (eql (string-lessp "xyz" "abcxyz" :end1 2 :start2 3) 2))
514 (test (not (string-lessp "xyzabc" "abcdef" :start1 3 :end2 3)))
515 (test (eql (string-lessp "aaaa" "z") 0))
516 (test (eql (string-lessp "pppTTTaTTTqqq" "pTTTxTTT" :start1 3 :start2 1) 6))
517 (test (eql (string-lessp "pppTTTaTTTqqq" "pTTTxTTT"
519 :start2 4 :end2 5) 6))
520 ;; (test (not (string-lessp (make-array 0 :element-type 'character)
521 ;; (make-array 0 :element-type 'base-char))))
522 (test (and (not (string-lessp "abc" "ABC"))
523 (not (string-lessp "ABC" "abc"))))
524 (test (not (string-lessp 'love 'hate)))
525 (test (= (string-lessp 'peace 'war) 0))
526 (test (not (string-lessp 'love 'love)))
527 (test (not (string-lessp #\a #\a)))
528 (test (= (string-lessp #\a #\b) 0))
529 (test (not (string-lessp #\z #\a)))
532 (test (not (string-greaterp "" "")))
533 (test (not (string-greaterp "dog" "dog")))
534 (test (not (string-greaterp " " " ")))
535 (test (eql (string-greaterp "abc" "") 0))
536 (test (not (string-greaterp "" "abc")))
537 (test (not (string-greaterp "ab" "abc")))
538 (test (eql (string-greaterp "abc" "ab") 2))
539 (test (eql (string-greaterp "aba" "aaa") 1))
540 (test (not (string-greaterp "aaa" "aba")))
541 (test (not (string-greaterp "my cat food" "your dog food" :start1 6 :start2 8)))
542 (test (not (string-greaterp "cat food 2 dollars" "dog food 3 dollars"
543 :start1 3 :end1 9 :start2 3 :end2 9)))
544 (test (eql (string-greaterp "xyzabcde" "abcd" :start1 3) 7))
545 (test (not (string-greaterp "abc" "abc" :end1 1)))
546 (test (eql (string-greaterp "xyzabc" "a" :start1 3 :end1 5) 4))
547 (test (eql (string-greaterp "xyzXYZ" "abcxyz" :start2 3) 3))
548 (test (eql (string-greaterp "abcxyz" "abcxyz" :end2 3) 3))
549 (test (not (string-greaterp "xyzXYZ" "abcxyz" :end1 2 :start2 3)))
550 (test (not (string-greaterp "xyzabc" "abcdef" :start1 3 :end2 3)))
551 (test (eql (string-greaterp "z" "aaaa") 0))
552 (test (eql (string-greaterp "pTTTxTTTqqq" "pppTTTaTTT" :start1 1 :start2 3) 4))
553 (test (eql (string-greaterp "pppTTTxTTTqqq" "pTTTaTTT"
555 :start2 4 :end2 5) 6))
556 ;; (test (not (string-greaterp (make-array 0 :element-type 'character)
557 ;; (make-array 0 :element-type 'base-char))))
558 (test (and (not (string-greaterp "abc" "ABC"))
559 (not (string-greaterp "ABC" "abc"))))
560 (test (= (string-greaterp 'love 'hate) 0))
561 (test (not (string-greaterp 'peace 'war)))
562 (test (not (string-greaterp 'love 'love)))
563 (test (not (string-greaterp #\a #\a)))
564 (test (not (string-greaterp #\a #\b)))
565 (test (= (string-greaterp #\z #\a) 0))
568 (test (eql (string-not-greaterp "" "") 0))
569 (test (eql (string-not-greaterp "dog" "dog") 3))
570 (test (eql (string-not-greaterp " " " ") 1))
571 (test (not (string-not-greaterp "abc" "")))
572 (test (eql (string-not-greaterp "ab" "abc") 2))
573 (test (eql (string-not-greaterp "aaa" "aba") 1))
574 (test (not (string-not-greaterp "aba" "aaa")))
575 (test (eql (string-not-greaterp "my cat food" "your dog food" :start1 6 :start2 8) 11))
576 (test (eql (string-not-greaterp "cat food 2 dollars" "dog food 3 dollars"
577 :start1 3 :end1 9 :start2 3 :end2 9) 9))
578 (test (eql (string-not-greaterp "xyzabc" "abcd" :start1 3) 6))
579 (test (eql (string-not-greaterp "abc" "abc" :end1 1) 1))
580 (test (eql (string-not-greaterp "xyzabc" "abc" :start1 3 :end1 5) 5))
581 (test (eql (string-not-greaterp "xyz" "abcxyzXYZ" :start2 3) 3))
582 (test (eql (string-not-greaterp "abc" "abcxyz" :end2 3) 3))
583 (test (eql (string-not-greaterp "xyz" "abcxyz" :end1 2 :start2 3) 2))
584 (test (eql (string-not-greaterp "xyzabc" "abcdef" :start1 3 :end2 3) 6))
585 (test (eql (string-not-greaterp "aaaa" "z") 0))
586 (test (eql (string-not-greaterp "pppTTTaTTTqqq" "pTTTxTTT" :start1 3 :start2 1) 6))
587 (test (eql (string-not-greaterp "pppTTTaTTTqqq" "pTTTxTTT"
589 :start2 4 :end2 5) 6))
590 ;; (test (eql (string-not-greaterp (make-array 0 :element-type 'character)
591 ;; (make-array 0 :element-type 'base-char)) 0))
592 (test (and (eql (string-not-greaterp "abc" "ABC") 3)
593 (eql (string-not-greaterp "ABC" "abc") 3)))
594 (test (not (string-not-greaterp 'love 'hate)))
595 (test (= (string-not-greaterp 'peace 'war) 0))
596 (test (= (string-not-greaterp 'love 'love) 4))
597 (test (= (string-not-greaterp #\a #\a) 1))
598 (test (= (string-not-greaterp #\a #\b) 0))
599 (test (not (string-not-greaterp #\z #\a)))
602 (test (eql (string-not-lessp "" "") 0))
603 (test (eql (string-not-lessp "dog" "dog") 3))
604 (test (eql (string-not-lessp " " " ") 1))
605 (test (eql (string-not-lessp "abc" "") 0))
606 (test (not (string-not-lessp "" "abc")))
607 (test (not (string-not-lessp "ab" "abc")))
608 (test (eql (string-not-lessp "abc" "ab") 2))
609 (test (eql (string-not-lessp "aba" "aaa") 1))
610 (test (not (string-not-lessp "aaa" "aba")))
611 (test (eql (string-not-lessp "my cat food" "your dog food" :start1 6 :start2 8) 11))
612 (test (eql (string-not-lessp "cat food 2 dollars" "dog food 3 dollars"
613 :start1 3 :end1 9 :start2 3 :end2 9) 9))
614 (test (eql (string-not-lessp "xyzabcde" "abcd" :start1 3) 7))
615 (test (not (string-not-lessp "abc" "abc" :end1 1)))
616 (test (eql (string-not-lessp "xyzabc" "a" :start1 3 :end1 5) 4))
617 (test (eql (string-not-lessp "xyzXYZ" "abcxyz" :start2 3) 3))
618 (test (eql (string-not-lessp "abcxyz" "abcxyz" :end2 3) 3))
619 (test (not (string-not-lessp "xyzXYZ" "abcxyz" :end1 2 :start2 3)))
620 (test (eql (string-not-lessp "xyzabc" "abcdef" :start1 3 :end2 3) 6))
621 (test (eql (string-not-lessp "z" "aaaa") 0))
622 (test (eql (string-not-lessp "pTTTxTTTqqq" "pppTTTaTTT" :start1 1 :start2 3) 4))
623 (test (eql (string-not-lessp "pppTTTxTTTqqq" "pTTTaTTT"
625 :start2 4 :end2 5) 6))
626 ;; (test (eql (string-not-lessp (make-array 0 :element-type 'character)
627 ;; (make-array 0 :element-type 'base-char)) 0))
628 (test (and (eql (string-not-lessp "abc" "ABC") 3)
629 (eql (string-not-lessp "ABC" "abc") 3)))
630 (test (= (string-not-lessp 'love 'hate) 0))
631 (test (not (string-not-lessp 'peace 'war)))
632 (test (= (string-not-lessp 'love 'love) 4))
633 (test (= (string-not-lessp #\a #\a) 1))
634 (test (not (string-not-lessp #\a #\b)))
635 (test (= (string-not-lessp #\z #\a) 0))
639 (test (stringp "aaaaaa"))
640 (test (stringp (make-array 0 :element-type 'character)))
641 ;; (test (stringp (make-array 0 :element-type 'base-char)))
642 ;; JSCL: an array of STANDARD-CHAR isn't a STRINGP yet, either
643 ;; (test (stringp (make-array 0 :element-type 'standard-char)))
644 (test (not (stringp #\a)))
645 (test (not (stringp 'a)))
646 (test (not (stringp '(string))))
648 (test (string= (make-string 3 :initial-element #\a) "aaa"))
649 ;; JSCL: no SCHAR, so disabled
650 ;; (test (let ((str (make-string 3)))
651 ;; (and (simple-string-p str)
652 ;; (setf (schar str 0) #\x)
653 ;; (setf (schar str 1) #\y)
654 ;; (setf (schar str 2) #\z)
655 ;; (string= str "xyz"))))
656 ;; JSCL: #\Space isn't read correctly yet
657 ;; (test (string= (make-string 1 :initial-element #\Space) " "))
658 (test (string= (make-string 0) ""))
660 ;; JSCL: BUG?: this barfs inside the JS function xstring(), and i don't know why.
661 ;; (test (subtypep (upgraded-array-element-type
662 ;; (array-element-type (make-string 3 :element-type 'standard-char)))