string-comparisons.lsp 28.3 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Fri Oct  4 06:32:41 2002
;;;; Contains: Tests of string comparison functions

(in-package :cl-test)

8 9
(compile-and-load "string-aux.lsp")

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
(deftest string=.1
  (not (string= "abc" (copy-seq "abc")))
  nil)

(deftest string=.2
  (string= "A" "a")
  nil)

(deftest string=.3
  (not (string= #\a "a"))
  nil)

(deftest string=.4
  (not (string= '|abc| (copy-seq "abc")))
  nil)

(deftest string=.5
  (not (string= (copy-seq "abc") '#:|abc|))
  nil)

;;; Test that it doesn't stop at null characters
(deftest string=.6
  (let ((s1 (copy-seq "abc"))
sds's avatar
sds committed
33 34
        (s2 (copy-seq "abd"))
        (c (or (code-char 0) #\a)))
35 36 37 38 39 40 41
    (setf (char s1 1) c)
    (setf (char s2 1) c)
    (values (length s1) (length s2) (string= s1 s2)))
  3 3 nil)

(deftest string=.7
  (loop for i from 0 to 3
sds's avatar
sds committed
42
        collect (not (string= "abc" "abd" :start1 0 :end1 i :end2 i)))
43 44 45 46
  (nil nil nil t))

(deftest string=.8
  (loop for i from 0 to 3
sds's avatar
sds committed
47
        collect (not (string= "abc" "ab" :end1 i)))
48 49 50 51
  (t t nil t))

(deftest string=.9
  (loop for i from 0 to 3
sds's avatar
sds committed
52
        collect (not (string= "abc" "abd" :start2 0 :end2 i :end1 i)))
53 54 55 56
  (nil nil nil t))

(deftest string=.10
  (loop for i from 0 to 3
sds's avatar
sds committed
57
        collect (not (string= "ab" "abc" :end2 i)))
58 59 60 61
  (t t nil t))

(deftest string=.11
  (loop for i from 0 to 3
sds's avatar
sds committed
62
        collect (not (string= "xyab" "ab" :start1 i)))
63 64 65 66
  (t t nil t))

(deftest string=.12
  (loop for i from 0 to 3
sds's avatar
sds committed
67
        collect (not (string= "ab" "xyab" :start2 i)))
68 69 70 71
  (t t nil t))

(deftest string=.13
  (loop for i from 0 to 3
sds's avatar
sds committed
72
        collect (not (string= "xyab" "ab" :start1 i :end1 nil)))
73 74 75 76
  (t t nil t))

(deftest string=.14
  (loop for i from 0 to 3
sds's avatar
sds committed
77
        collect (not (string= "ab" "xyab" :start2 i :end2 nil)))
78 79
  (t t nil t))

pfdietz's avatar
pfdietz committed
80 81 82 83
;;; Keyword argument processing

(deftest string-comparison.allow-other-keys.1
  (loop for fn in '(string= string<= string>= string/= string< string>
sds's avatar
sds committed
84 85 86 87 88 89
                    string-equal string-not-greaterp string-not-lessp
                    string-not-equal string-lessp string-greaterp)
        for expected in '(nil 0 nil 0 0 nil nil 0 nil 0 0 nil)
        for result = (funcall fn "a" "b" :allow-other-keys t :foo nil)
        unless (eql result expected)
        collect (list fn expected result))
pfdietz's avatar
pfdietz committed
90 91 92 93
  nil)

(deftest string-comparison.allow-other-keys.2
  (loop for fn in '(string= string<= string>= string/= string< string>
sds's avatar
sds committed
94 95 96 97 98 99 100
                    string-equal string-not-greaterp string-not-lessp
                    string-not-equal string-lessp string-greaterp)
        for expected in '(nil nil 0 0 nil 0 nil nil 0 0 nil 0)
        for result = (funcall fn "c" "b" :allow-other-keys t
                              :allow-other-keys nil :foo 1)
        unless (eql result expected)
        collect (list fn expected result))
pfdietz's avatar
pfdietz committed
101 102 103 104
  nil)

(deftest string-comparison.allow-other-keys.3
  (loop for fn in '(string= string<= string>= string/= string< string>
sds's avatar
sds committed
105 106 107 108 109 110
                    string-equal string-not-greaterp string-not-lessp
                    string-not-equal string-lessp string-greaterp)
        for expected in '(nil 0 nil 0 0 nil nil 0 nil 0 0 nil)
        for result = (funcall fn "a" "b" :allow-other-keys nil)
        unless (eql result expected)
        collect (list fn expected result))
pfdietz's avatar
pfdietz committed
111 112 113
  nil)


114 115 116 117 118 119
;;; Order of evaluation

(deftest string=.order.1
  (let ((i 0) x y)
    (values
     (string= (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
120
              (progn (setf y (incf i)) "abd"))
121 122 123 124 125 126 127
     i x y))
  nil 2 1 2)

(deftest string=.order.2
  (let ((i 0) a b c d e f)
    (values
     (string= (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
128 129 130 131 132 133
              (progn (setf b (incf i)) "abd")
              :start1 (progn (setf c (incf i)) 0)
              :start2 (progn (setf d (incf i)) 0)
              :end1 (progn (setf e (incf i)) nil)
              :end2 (progn (setf f (incf i)) nil)
              )
134 135 136 137 138 139 140
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string=.order.3
  (let ((i 0) a b c d e f)
    (values
     (string= (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
141 142 143 144 145 146
              (progn (setf b (incf i)) "abd")
              :end2 (progn (setf c (incf i)) nil)
              :end1 (progn (setf d (incf i)) nil)
              :start2 (progn (setf e (incf i)) 0)
              :start1 (progn (setf f (incf i)) 0)
              )
147 148 149 150 151 152 153
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string<=.order.1
  (let ((i 0) x y)
    (values
     (string<= (progn (setf x (incf i)) "abf")
sds's avatar
sds committed
154
               (progn (setf y (incf i)) "abd"))
155 156 157 158 159 160 161
     i x y))
  nil 2 1 2)

(deftest string<=.order.2
  (let ((i 0) a b c d e f)
    (values
     (string<= (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
162 163 164 165 166 167
               (progn (setf b (incf i)) "abd")
               :start1 (progn (setf c (incf i)) 0)
               :start2 (progn (setf d (incf i)) 0)
               :end1 (progn (setf e (incf i)) nil)
               :end2 (progn (setf f (incf i)) nil)
               )
168 169 170 171 172 173 174
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string<=.order.3
  (let ((i 0) a b c d e f)
    (values
     (string<= (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
175 176 177 178 179 180
               (progn (setf b (incf i)) "abd")
               :end2 (progn (setf c (incf i)) nil)
               :end1 (progn (setf d (incf i)) nil)
               :start2 (progn (setf e (incf i)) 0)
               :start1 (progn (setf f (incf i)) 0)
               )
181 182 183 184 185 186 187
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string<.order.1
  (let ((i 0) x y)
    (values
     (string< (progn (setf x (incf i)) "abf")
sds's avatar
sds committed
188
              (progn (setf y (incf i)) "abd"))
189 190 191 192 193 194 195
     i x y))
  nil 2 1 2)

(deftest string<.order.2
  (let ((i 0) a b c d e f)
    (values
     (string< (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
196 197 198 199 200 201
              (progn (setf b (incf i)) "abd")
              :start1 (progn (setf c (incf i)) 0)
              :start2 (progn (setf d (incf i)) 0)
              :end1 (progn (setf e (incf i)) nil)
              :end2 (progn (setf f (incf i)) nil)
              )
202 203 204 205 206 207 208
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string<.order.3
  (let ((i 0) a b c d e f)
    (values
     (string< (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
209 210 211 212 213 214
              (progn (setf b (incf i)) "abd")
              :end2 (progn (setf c (incf i)) nil)
              :end1 (progn (setf d (incf i)) nil)
              :start2 (progn (setf e (incf i)) 0)
              :start1 (progn (setf f (incf i)) 0)
              )
215 216 217 218 219 220 221 222
     i a b c d e f))
  nil 6 1 2 3 4 5 6)


(deftest string/=.order.1
  (let ((i 0) x y)
    (values
     (string/= (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
223
               (progn (setf y (incf i)) "abc"))
224 225 226 227 228 229 230
     i x y))
  nil 2 1 2)

(deftest string/=.order.2
  (let ((i 0) a b c d e f)
    (values
     (string/= (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
231 232 233 234 235 236
               (progn (setf b (incf i)) "abc")
               :start1 (progn (setf c (incf i)) 0)
               :start2 (progn (setf d (incf i)) 0)
               :end1 (progn (setf e (incf i)) nil)
               :end2 (progn (setf f (incf i)) nil)
               )
237 238 239 240 241 242 243
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string/=.order.3
  (let ((i 0) a b c d e f)
    (values
     (string/= (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
244 245 246 247 248 249
               (progn (setf b (incf i)) "abc")
               :end2 (progn (setf c (incf i)) nil)
               :end1 (progn (setf d (incf i)) nil)
               :start2 (progn (setf e (incf i)) 0)
               :start1 (progn (setf f (incf i)) 0)
               )
250 251 252 253 254 255 256
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string>=.order.1
  (let ((i 0) x y)
    (values
     (string<= (progn (setf x (incf i)) "abf")
sds's avatar
sds committed
257
               (progn (setf y (incf i)) "abd"))
258 259 260 261 262 263 264
     i x y))
  nil 2 1 2)

(deftest string>=.order.2
  (let ((i 0) a b c d e f)
    (values
     (string>= (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
265 266 267 268 269 270
               (progn (setf b (incf i)) "abd")
               :start1 (progn (setf c (incf i)) 0)
               :start2 (progn (setf d (incf i)) 0)
               :end1 (progn (setf e (incf i)) nil)
               :end2 (progn (setf f (incf i)) nil)
               )
271 272 273 274 275 276 277
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string>=.order.3
  (let ((i 0) a b c d e f)
    (values
     (string>= (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
278 279 280 281 282 283
               (progn (setf b (incf i)) "abd")
               :end2 (progn (setf c (incf i)) nil)
               :end1 (progn (setf d (incf i)) nil)
               :start2 (progn (setf e (incf i)) 0)
               :start1 (progn (setf f (incf i)) 0)
               )
284 285 286 287 288 289 290
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string>.order.1
  (let ((i 0) x y)
    (values
     (string> (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
291
              (progn (setf y (incf i)) "abd"))
292 293 294 295 296 297 298
     i x y))
  nil 2 1 2)

(deftest string>.order.2
  (let ((i 0) a b c d e f)
    (values
     (string> (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
299 300 301 302 303 304
              (progn (setf b (incf i)) "abd")
              :start1 (progn (setf c (incf i)) 0)
              :start2 (progn (setf d (incf i)) 0)
              :end1 (progn (setf e (incf i)) nil)
              :end2 (progn (setf f (incf i)) nil)
              )
305 306 307 308 309 310 311
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string>.order.3
  (let ((i 0) a b c d e f)
    (values
     (string> (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
312 313 314 315 316 317
              (progn (setf b (incf i)) "abd")
              :end2 (progn (setf c (incf i)) nil)
              :end1 (progn (setf d (incf i)) nil)
              :start2 (progn (setf e (incf i)) 0)
              :start1 (progn (setf f (incf i)) 0)
              )
318 319 320 321 322 323 324 325
     i a b c d e f))
  nil 6 1 2 3 4 5 6)


(deftest string-equal.order.1
  (let ((i 0) x y)
    (values
     (string-equal (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
326
              (progn (setf y (incf i)) "abd"))
327 328 329 330 331 332 333
     i x y))
  nil 2 1 2)

(deftest string-equal.order.2
  (let ((i 0) a b c d e f)
    (values
     (string-equal (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
334 335 336 337 338 339
              (progn (setf b (incf i)) "abd")
              :start1 (progn (setf c (incf i)) 0)
              :start2 (progn (setf d (incf i)) 0)
              :end1 (progn (setf e (incf i)) nil)
              :end2 (progn (setf f (incf i)) nil)
              )
340 341 342 343 344 345 346
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-equal.order.3
  (let ((i 0) a b c d e f)
    (values
     (string-equal (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
347 348 349 350 351 352
              (progn (setf b (incf i)) "abd")
              :end2 (progn (setf c (incf i)) nil)
              :end1 (progn (setf d (incf i)) nil)
              :start2 (progn (setf e (incf i)) 0)
              :start1 (progn (setf f (incf i)) 0)
              )
353 354 355 356 357 358 359
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-not-greaterp.order.1
  (let ((i 0) x y)
    (values
     (string-not-greaterp (progn (setf x (incf i)) "abf")
sds's avatar
sds committed
360
                       (progn (setf y (incf i)) "abd"))
361 362 363 364 365 366 367
     i x y))
  nil 2 1 2)

(deftest string-not-greaterp.order.2
  (let ((i 0) a b c d e f)
    (values
     (string-not-greaterp (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
368 369 370 371 372 373
               (progn (setf b (incf i)) "abd")
               :start1 (progn (setf c (incf i)) 0)
               :start2 (progn (setf d (incf i)) 0)
               :end1 (progn (setf e (incf i)) nil)
               :end2 (progn (setf f (incf i)) nil)
               )
374 375 376 377 378 379 380
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-not-greaterp.order.3
  (let ((i 0) a b c d e f)
    (values
     (string-not-greaterp (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
381 382 383 384 385 386
               (progn (setf b (incf i)) "abd")
               :end2 (progn (setf c (incf i)) nil)
               :end1 (progn (setf d (incf i)) nil)
               :start2 (progn (setf e (incf i)) 0)
               :start1 (progn (setf f (incf i)) 0)
               )
387 388 389 390 391 392 393
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-lessp.order.1
  (let ((i 0) x y)
    (values
     (string-lessp (progn (setf x (incf i)) "abf")
sds's avatar
sds committed
394
              (progn (setf y (incf i)) "abd"))
395 396 397 398 399 400 401
     i x y))
  nil 2 1 2)

(deftest string-lessp.order.2
  (let ((i 0) a b c d e f)
    (values
     (string-lessp (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
402 403 404 405 406 407
              (progn (setf b (incf i)) "abd")
              :start1 (progn (setf c (incf i)) 0)
              :start2 (progn (setf d (incf i)) 0)
              :end1 (progn (setf e (incf i)) nil)
              :end2 (progn (setf f (incf i)) nil)
              )
408 409 410 411 412 413 414
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-lessp.order.3
  (let ((i 0) a b c d e f)
    (values
     (string-lessp (progn (setf a (incf i)) "abf")
sds's avatar
sds committed
415 416 417 418 419 420
              (progn (setf b (incf i)) "abd")
              :end2 (progn (setf c (incf i)) nil)
              :end1 (progn (setf d (incf i)) nil)
              :start2 (progn (setf e (incf i)) 0)
              :start1 (progn (setf f (incf i)) 0)
              )
421 422 423 424 425 426 427 428
     i a b c d e f))
  nil 6 1 2 3 4 5 6)


(deftest string-not-equal.order.1
  (let ((i 0) x y)
    (values
     (string-not-equal (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
429
               (progn (setf y (incf i)) "abc"))
430 431 432 433 434 435 436
     i x y))
  nil 2 1 2)

(deftest string-not-equal.order.2
  (let ((i 0) a b c d e f)
    (values
     (string-not-equal (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
437 438 439 440 441 442
               (progn (setf b (incf i)) "abc")
               :start1 (progn (setf c (incf i)) 0)
               :start2 (progn (setf d (incf i)) 0)
               :end1 (progn (setf e (incf i)) nil)
               :end2 (progn (setf f (incf i)) nil)
               )
443 444 445 446 447 448 449
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-not-equal.order.3
  (let ((i 0) a b c d e f)
    (values
     (string-not-equal (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
450 451 452 453 454 455
               (progn (setf b (incf i)) "abc")
               :end2 (progn (setf c (incf i)) nil)
               :end1 (progn (setf d (incf i)) nil)
               :start2 (progn (setf e (incf i)) 0)
               :start1 (progn (setf f (incf i)) 0)
               )
456 457 458 459 460 461 462
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-not-lessp.order.1
  (let ((i 0) x y)
    (values
     (string-not-lessp (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
463
                       (progn (setf y (incf i)) "abd"))
464 465 466 467 468 469 470
     i x y))
  nil 2 1 2)

(deftest string-not-lessp.order.2
  (let ((i 0) a b c d e f)
    (values
     (string-not-lessp (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
471 472 473 474 475 476
               (progn (setf b (incf i)) "abd")
               :start1 (progn (setf c (incf i)) 0)
               :start2 (progn (setf d (incf i)) 0)
               :end1 (progn (setf e (incf i)) nil)
               :end2 (progn (setf f (incf i)) nil)
               )
477 478 479 480 481 482 483
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-not-lessp.order.3
  (let ((i 0) a b c d e f)
    (values
     (string-not-lessp (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
484 485 486 487 488 489
               (progn (setf b (incf i)) "abd")
               :end2 (progn (setf c (incf i)) nil)
               :end1 (progn (setf d (incf i)) nil)
               :start2 (progn (setf e (incf i)) 0)
               :start1 (progn (setf f (incf i)) 0)
               )
490 491 492 493 494 495 496
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-greaterp.order.1
  (let ((i 0) x y)
    (values
     (string-greaterp (progn (setf x (incf i)) "abc")
sds's avatar
sds committed
497
              (progn (setf y (incf i)) "abd"))
498 499 500 501 502 503 504
     i x y))
  nil 2 1 2)

(deftest string-greaterp.order.2
  (let ((i 0) a b c d e f)
    (values
     (string-greaterp (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
505 506 507 508 509 510
              (progn (setf b (incf i)) "abd")
              :start1 (progn (setf c (incf i)) 0)
              :start2 (progn (setf d (incf i)) 0)
              :end1 (progn (setf e (incf i)) nil)
              :end2 (progn (setf f (incf i)) nil)
              )
511 512 513 514 515 516 517
     i a b c d e f))
  nil 6 1 2 3 4 5 6)

(deftest string-greaterp.order.3
  (let ((i 0) a b c d e f)
    (values
     (string-greaterp (progn (setf a (incf i)) "abc")
sds's avatar
sds committed
518 519 520 521 522 523
              (progn (setf b (incf i)) "abd")
              :end2 (progn (setf c (incf i)) nil)
              :end1 (progn (setf d (incf i)) nil)
              :start2 (progn (setf e (incf i)) 0)
              :start1 (progn (setf f (incf i)) 0)
              )
524 525 526 527
     i a b c d e f))
  nil 6 1 2 3 4 5 6)


528 529 530 531
;;; Random tests (of all the string comparson functions)

(deftest random-string-comparison-tests
  (loop for cmp in '(= /= < > <= >=)
sds's avatar
sds committed
532 533 534 535 536
        append
        (loop for case in '(nil t)
              collect
              (list cmp case
                    (random-string-compare-test 10 cmp case 1000))))
537 538 539
  ((= nil 0) (= t 0) (/= nil 0) (/= t 0) (< nil 0) (< t 0)
   (> nil 0) (> t 0) (<= nil 0) (<= t 0) (>= nil 0) (>= t 0)))

540 541 542
;;; Tests on nil arrays

(deftest string=.nil-array.1
543
  :notes (:nil-vectors-are-strings)
544 545 546 547 548 549 550 551 552 553 554 555
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (notnot (string= s1 s1))
     (notnot (string= s1 (make-array '(0) :element-type nil)))
     (notnot (string= s1 (make-array '(0) :element-type 'base-char)))
     (notnot (string= s1 ""))
     (notnot (string= "" s1))
     (string= s1 "a")
     (string= "a" s1)))
  t t t t t nil nil)

(deftest string/=.nil-array.1
556
  :notes (:nil-vectors-are-strings)
557 558 559 560 561 562 563 564 565 566 567 568
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string/= s1 s1)
     (string/= s1 (make-array '(0) :element-type nil))
     (string/= s1 (make-array '(0) :element-type 'base-char))
     (string/= s1 "")
     (string/= "" s1)
     (string/= s1 "a")
     (string/= "a" s1)))
   nil nil nil nil nil 0 0)

(deftest string<.nil-array.1
569
  :notes (:nil-vectors-are-strings)
570 571 572 573 574 575 576 577 578 579 580 581
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string< s1 s1)
     (string< s1 (make-array '(0) :element-type nil))
     (string< s1 (make-array '(0) :element-type 'base-char))
     (string< s1 "")
     (string< "" s1)
     (string< s1 "a")
     (string< "a" s1)))
  nil nil nil nil nil 0 nil)

(deftest string<=.nil-array.1
582
  :notes (:nil-vectors-are-strings)
583 584 585 586 587 588 589 590 591 592 593 594
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string<= s1 s1)
     (string<= s1 (make-array '(0) :element-type nil))
     (string<= s1 (make-array '(0) :element-type 'base-char))
     (string<= s1 "")
     (string<= "" s1)
     (string<= s1 "a")
     (string<= "a" s1)))
  0 0 0 0 0 0 nil)

(deftest string>.nil-array.1
595
  :notes (:nil-vectors-are-strings)
596 597 598 599 600 601 602 603 604 605 606 607
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string> s1 s1)
     (string> s1 (make-array '(0) :element-type nil))
     (string> s1 (make-array '(0) :element-type 'base-char))
     (string> s1 "")
     (string> "" s1)
     (string> s1 "a")
     (string> "a" s1)))
  nil nil nil nil nil nil 0)

(deftest string>=.nil-array.1
608
  :notes (:nil-vectors-are-strings)
609 610 611 612 613 614 615 616 617 618 619 620
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string>= s1 s1)
     (string>= s1 (make-array '(0) :element-type nil))
     (string>= s1 (make-array '(0) :element-type 'base-char))
     (string>= s1 "")
     (string>= "" s1)
     (string>= s1 "a")
     (string>= "a" s1)))
  0 0 0 0 0 nil 0)

(deftest string-equal.nil-array.1
621
  :notes (:nil-vectors-are-strings)
622 623 624 625 626 627 628 629 630 631 632 633
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (notnot (string-equal s1 s1))
     (notnot (string-equal s1 (make-array '(0) :element-type nil)))
     (notnot (string-equal s1 (make-array '(0) :element-type 'base-char)))
     (notnot (string-equal s1 ""))
     (notnot (string-equal "" s1))
     (string-equal s1 "a")
     (string-equal "a" s1)))
  t t t t t nil nil)

(deftest string-not-equal.nil-array.1
634
  :notes (:nil-vectors-are-strings)
635 636 637 638 639 640 641 642 643 644 645 646
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string-not-equal s1 s1)
     (string-not-equal s1 (make-array '(0) :element-type nil))
     (string-not-equal s1 (make-array '(0) :element-type 'base-char))
     (string-not-equal s1 "")
     (string-not-equal "" s1)
     (string-not-equal s1 "a")
     (string-not-equal "a" s1)))
   nil nil nil nil nil 0 0)

(deftest string-lessp.nil-array.1
647
  :notes (:nil-vectors-are-strings)
648 649 650 651 652 653 654 655 656 657 658 659
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string-lessp s1 s1)
     (string-lessp s1 (make-array '(0) :element-type nil))
     (string-lessp s1 (make-array '(0) :element-type 'base-char))
     (string-lessp s1 "")
     (string-lessp "" s1)
     (string-lessp s1 "a")
     (string-lessp "a" s1)))
  nil nil nil nil nil 0 nil)

(deftest string-not-greaterp.nil-array.1
660
  :notes (:nil-vectors-are-strings)
661 662 663 664 665 666 667 668 669 670 671 672
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string-not-greaterp s1 s1)
     (string-not-greaterp s1 (make-array '(0) :element-type nil))
     (string-not-greaterp s1 (make-array '(0) :element-type 'base-char))
     (string-not-greaterp s1 "")
     (string-not-greaterp "" s1)
     (string-not-greaterp s1 "a")
     (string-not-greaterp "a" s1)))
  0 0 0 0 0 0 nil)

(deftest string-greaterp.nil-array.1
673
  :notes (:nil-vectors-are-strings)
674 675 676 677 678 679 680 681 682 683 684 685
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string-greaterp s1 s1)
     (string-greaterp s1 (make-array '(0) :element-type nil))
     (string-greaterp s1 (make-array '(0) :element-type 'base-char))
     (string-greaterp s1 "")
     (string-greaterp "" s1)
     (string-greaterp s1 "a")
     (string-greaterp "a" s1)))
  nil nil nil nil nil nil 0)

(deftest string-not-lessp.nil-array.1
686
  :notes (:nil-vectors-are-strings)
687 688 689 690 691 692 693 694 695 696
  (let ((s1 (make-array '(0) :element-type nil)))
    (values
     (string-not-lessp s1 s1)
     (string-not-lessp s1 (make-array '(0) :element-type nil))
     (string-not-lessp s1 (make-array '(0) :element-type 'base-char))
     (string-not-lessp s1 "")
     (string-not-lessp "" s1)
     (string-not-lessp s1 "a")
     (string-not-lessp "a" s1)))
  0 0 0 0 0 nil 0)
pfdietz's avatar
pfdietz committed
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721

;;; Error cases

(deftest string=.error.1
  (signals-error (string=) program-error)
  t)

(deftest string=.error.2
  (signals-error (string= "") program-error)
  t)

(deftest string=.error.3
  (signals-error (string= "a" "b" nil nil) program-error)
  t)

(deftest string=.error.4
  (signals-error (string= "a" "b" :start1) program-error)
  t)

(deftest string=.error.5
  (signals-error (string= "a" "b" 1 nil) program-error)
  t)

(deftest string=.error.6
  (signals-error (string= "a" "b" :allow-other-keys nil
sds's avatar
sds committed
722 723
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
  t)

(deftest string/=.error.1
  (signals-error (string/=) program-error)
  t)

(deftest string/=.error.2
  (signals-error (string/= "") program-error)
  t)

(deftest string/=.error.3
  (signals-error (string/= "a" "b" nil nil) program-error)
  t)

(deftest string/=.error.4
  (signals-error (string/= "a" "b" :start1) program-error)
  t)

(deftest string/=.error.5
  (signals-error (string/= "a" "b" 1 nil) program-error)
  t)

(deftest string/=.error.6
  (signals-error (string/= "a" "b" :allow-other-keys nil
sds's avatar
sds committed
748 749
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
  t)


(deftest string<.error.1
  (signals-error (string<) program-error)
  t)

(deftest string<.error.2
  (signals-error (string< "") program-error)
  t)

(deftest string<.error.3
  (signals-error (string< "a" "b" nil nil) program-error)
  t)

(deftest string<.error.4
  (signals-error (string< "a" "b" :start1) program-error)
  t)

(deftest string<.error.5
  (signals-error (string< "a" "b" 1 nil) program-error)
  t)

(deftest string<.error.6
  (signals-error (string< "a" "b" :allow-other-keys nil
sds's avatar
sds committed
775 776
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
  t)


(deftest string<=.error.1
  (signals-error (string<=) program-error)
  t)

(deftest string<=.error.2
  (signals-error (string<= "") program-error)
  t)

(deftest string<=.error.3
  (signals-error (string<= "a" "b" nil nil) program-error)
  t)

(deftest string<=.error.4
  (signals-error (string<= "a" "b" :start1) program-error)
  t)

(deftest string<=.error.5
  (signals-error (string<= "a" "b" 1 nil) program-error)
  t)

(deftest string<=.error.6
  (signals-error (string<= "a" "b" :allow-other-keys nil
sds's avatar
sds committed
802 803
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
  t)


(deftest string>.error.1
  (signals-error (string>) program-error)
  t)

(deftest string>.error.2
  (signals-error (string> "") program-error)
  t)

(deftest string>.error.3
  (signals-error (string> "a" "b" nil nil) program-error)
  t)

(deftest string>.error.4
  (signals-error (string> "a" "b" :start1) program-error)
  t)

(deftest string>.error.5
  (signals-error (string> "a" "b" 1 nil) program-error)
  t)

(deftest string>.error.6
  (signals-error (string> "a" "b" :allow-other-keys nil
sds's avatar
sds committed
829 830
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
  t)


(deftest string>=.error.1
  (signals-error (string>=) program-error)
  t)

(deftest string>=.error.2
  (signals-error (string>= "") program-error)
  t)

(deftest string>=.error.3
  (signals-error (string>= "a" "b" nil nil) program-error)
  t)

(deftest string>=.error.4
  (signals-error (string>= "a" "b" :start1) program-error)
  t)

(deftest string>=.error.5
  (signals-error (string>= "a" "b" 1 nil) program-error)
  t)

(deftest string>=.error.6
  (signals-error (string>= "a" "b" :allow-other-keys nil
sds's avatar
sds committed
856 857
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882
  t)


(deftest string-equal.error.1
  (signals-error (string-equal) program-error)
  t)

(deftest string-equal.error.2
  (signals-error (string-equal "") program-error)
  t)

(deftest string-equal.error.3
  (signals-error (string-equal "a" "b" nil nil) program-error)
  t)

(deftest string-equal.error.4
  (signals-error (string-equal "a" "b" :start1) program-error)
  t)

(deftest string-equal.error.5
  (signals-error (string-equal "a" "b" 1 nil) program-error)
  t)

(deftest string-equal.error.6
  (signals-error (string-equal "a" "b" :allow-other-keys nil
sds's avatar
sds committed
883 884
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
  t)

(deftest string-not-equal.error.1
  (signals-error (string-not-equal) program-error)
  t)

(deftest string-not-equal.error.2
  (signals-error (string-not-equal "") program-error)
  t)

(deftest string-not-equal.error.3
  (signals-error (string-not-equal "a" "b" nil nil) program-error)
  t)

(deftest string-not-equal.error.4
  (signals-error (string-not-equal "a" "b" :start1) program-error)
  t)

(deftest string-not-equal.error.5
  (signals-error (string-not-equal "a" "b" 1 nil) program-error)
  t)

(deftest string-not-equal.error.6
  (signals-error (string-not-equal "a" "b" :allow-other-keys nil
sds's avatar
sds committed
909 910
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
  t)

(deftest string-lessp.error.1
  (signals-error (string-lessp) program-error)
  t)

(deftest string-lessp.error.2
  (signals-error (string-lessp "") program-error)
  t)

(deftest string-lessp.error.3
  (signals-error (string-lessp "a" "b" nil nil) program-error)
  t)

(deftest string-lessp.error.4
  (signals-error (string-lessp "a" "b" :start1) program-error)
  t)

(deftest string-lessp.error.5
  (signals-error (string-lessp "a" "b" 1 nil) program-error)
  t)

(deftest string-lessp.error.6
  (signals-error (string-lessp "a" "b" :allow-other-keys nil
sds's avatar
sds committed
935 936
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
  t)

(deftest string-greaterp.error.1
  (signals-error (string-greaterp) program-error)
  t)

(deftest string-greaterp.error.2
  (signals-error (string-greaterp "") program-error)
  t)

(deftest string-greaterp.error.3
  (signals-error (string-greaterp "a" "b" nil nil) program-error)
  t)

(deftest string-greaterp.error.4
  (signals-error (string-greaterp "a" "b" :start1) program-error)
  t)

(deftest string-greaterp.error.5
  (signals-error (string-greaterp "a" "b" 1 nil) program-error)
  t)

(deftest string-greaterp.error.6
  (signals-error (string-greaterp "a" "b" :allow-other-keys nil
sds's avatar
sds committed
961 962
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986
  t)

(deftest string-not-lessp.error.1
  (signals-error (string-not-lessp) program-error)
  t)

(deftest string-not-lessp.error.2
  (signals-error (string-not-lessp "") program-error)
  t)

(deftest string-not-lessp.error.3
  (signals-error (string-not-lessp "a" "b" nil nil) program-error)
  t)

(deftest string-not-lessp.error.4
  (signals-error (string-not-lessp "a" "b" :start1) program-error)
  t)

(deftest string-not-lessp.error.5
  (signals-error (string-not-lessp "a" "b" 1 nil) program-error)
  t)

(deftest string-not-lessp.error.6
  (signals-error (string-not-lessp "a" "b" :allow-other-keys nil
sds's avatar
sds committed
987 988
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
  t)

(deftest string-not-greaterp.error.1
  (signals-error (string-not-greaterp) program-error)
  t)

(deftest string-not-greaterp.error.2
  (signals-error (string-not-greaterp "") program-error)
  t)

(deftest string-not-greaterp.error.3
  (signals-error (string-not-greaterp "a" "b" nil nil) program-error)
  t)

(deftest string-not-greaterp.error.4
  (signals-error (string-not-greaterp "a" "b" :start1) program-error)
  t)

(deftest string-not-greaterp.error.5
  (signals-error (string-not-greaterp "a" "b" 1 nil) program-error)
  t)

(deftest string-not-greaterp.error.6
  (signals-error (string-not-greaterp "a" "b" :allow-other-keys nil
sds's avatar
sds committed
1013 1014
                          :allow-other-keys t :foo 'bar)
                 program-error)
pfdietz's avatar
pfdietz committed
1015
  t)