nstring-upcase.lsp 2.52 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Oct  3 21:12:40 2002
;;;; Contains: Tests for NSTRING-UPCASE

(in-package :cl-test)

(deftest nstring-upcase.1
  (let* ((s (copy-seq "a"))
	 (s2 (nstring-upcase s)))
11
    (values (eqt s s2) s))
12
13
14
15
16
  t "A")

(deftest nstring-upcase.2
  (let* ((s (copy-seq "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
	 (s2 (nstring-upcase s)))
17
    (values (eqt s s2) s))
18
19
20
21
22
23
  t
  "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")  

(deftest nstring-upcase.3
  (let* ((s (copy-seq "0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ "))
	 (s2 (nstring-upcase s)))
24
    (values (eqt s s2) s))
25
26
27
28
29
30
31
  t
  "0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ ")

(deftest nstring-upcase.6
  (let* ((s (make-array 6 :element-type 'character
			:initial-contents '(#\a #\b #\c #\d #\e #\f)))
	 (s2 (nstring-upcase s)))
32
    (values (eqt s s2) s))
33
34
35
36
37
38
  t "ABCDEF")

(deftest nstring-upcase.7
  (let* ((s (make-array 6 :element-type 'standard-char
			:initial-contents '(#\a #\b #\7 #\d #\e #\f)))
	 (s2 (nstring-upcase s)))
39
    (values (eqt s s2) s))
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  t "AB7DEF")

;; Tests with :start, :end

(deftest nstring-upcase.8
  (let ((s "abcdef"))
    (loop for i from 0 to 6
	  collect (nstring-upcase (copy-seq s) :start i)))
  ("ABCDEF" "aBCDEF" "abCDEF" "abcDEF" "abcdEF" "abcdeF" "abcdef"))

(deftest nstring-upcase.9
  (let ((s "abcdef"))
    (loop for i from 0 to 6
	  collect 
	  (nstring-upcase (copy-seq s) :start i :end nil)))
  ("ABCDEF" "aBCDEF" "abCDEF" "abcDEF" "abcdEF" "abcdeF" "abcdef"))

(deftest nstring-upcase.10
  (let ((s "abcde"))
     (loop for i from 0 to 4
	   collect (loop for j from i to 5
			 collect (nstring-upcase (copy-seq s)
						 :start i :end j))))
  (("abcde" "Abcde" "ABcde" "ABCde" "ABCDe" "ABCDE")
   ("abcde" "aBcde" "aBCde" "aBCDe" "aBCDE")
   ("abcde" "abCde" "abCDe" "abCDE")
   ("abcde" "abcDe" "abcDE")
   ("abcde" "abcdE")))

  
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;;; Error cases

(deftest nstring-upcase.error.1
  (classify-error (nstring-upcase))
  program-error)

(deftest nstring-upcase.error.2
  (classify-error (nstring-upcase (copy-seq "abc") :bad t))
  program-error)

(deftest nstring-upcase.error.3
  (classify-error (nstring-upcase (copy-seq "abc") :start))
  program-error)

(deftest nstring-upcase.error.4
  (classify-error (nstring-upcase (copy-seq "abc") :bad t
				      :allow-other-keys nil))
  program-error)

(deftest nstring-upcase.error.5
  (classify-error (nstring-upcase (copy-seq "abc") :end))
  program-error)

(deftest nstring-upcase.error.6
  (classify-error (nstring-upcase (copy-seq "abc") 1 2))
  program-error)