~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to ansi-tests/nstring-upcase.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;-*- Mode:     Lisp -*-
 
2
;;;; Author:   Paul Dietz
 
3
;;;; Created:  Thu Oct  3 21:12:40 2002
 
4
;;;; Contains: Tests for NSTRING-UPCASE
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
(deftest nstring-upcase.1
 
9
  (let* ((s (copy-seq "a"))
 
10
         (s2 (nstring-upcase s)))
 
11
    (values (eqt s s2) s))
 
12
  t "A")
 
13
 
 
14
(deftest nstring-upcase.2
 
15
  (let* ((s (copy-seq "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
 
16
         (s2 (nstring-upcase s)))
 
17
    (values (eqt s s2) s))
 
18
  t
 
19
  "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")  
 
20
 
 
21
(deftest nstring-upcase.3
 
22
  (let* ((s (copy-seq "0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ "))
 
23
         (s2 (nstring-upcase s)))
 
24
    (values (eqt s s2) s))
 
25
  t
 
26
  "0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ ")
 
27
 
 
28
(deftest nstring-upcase.6
 
29
  (let* ((s (make-array 6 :element-type 'character
 
30
                        :initial-contents '(#\a #\b #\c #\d #\e #\f)))
 
31
         (s2 (nstring-upcase s)))
 
32
    (values (eqt s s2) s))
 
33
  t "ABCDEF")
 
34
 
 
35
(deftest nstring-upcase.7
 
36
  (let* ((s (make-array 6 :element-type 'standard-char
 
37
                        :initial-contents '(#\a #\b #\7 #\d #\e #\f)))
 
38
         (s2 (nstring-upcase s)))
 
39
    (values (eqt s s2) s))
 
40
  t "AB7DEF")
 
41
 
 
42
;; Tests with :start, :end
 
43
 
 
44
(deftest nstring-upcase.8
 
45
  (let ((s "abcdef"))
 
46
    (loop for i from 0 to 6
 
47
          collect (nstring-upcase (copy-seq s) :start i)))
 
48
  ("ABCDEF" "aBCDEF" "abCDEF" "abcDEF" "abcdEF" "abcdeF" "abcdef"))
 
49
 
 
50
(deftest nstring-upcase.9
 
51
  (let ((s "abcdef"))
 
52
    (loop for i from 0 to 6
 
53
          collect 
 
54
          (nstring-upcase (copy-seq s) :start i :end nil)))
 
55
  ("ABCDEF" "aBCDEF" "abCDEF" "abcDEF" "abcdEF" "abcdeF" "abcdef"))
 
56
 
 
57
(deftest nstring-upcase.10
 
58
  (let ((s "abcde"))
 
59
     (loop for i from 0 to 4
 
60
           collect (loop for j from i to 5
 
61
                         collect (nstring-upcase (copy-seq s)
 
62
                                                 :start i :end j))))
 
63
  (("abcde" "Abcde" "ABcde" "ABCde" "ABCDe" "ABCDE")
 
64
   ("abcde" "aBcde" "aBCde" "aBCDe" "aBCDE")
 
65
   ("abcde" "abCde" "abCDe" "abCDE")
 
66
   ("abcde" "abcDe" "abcDE")
 
67
   ("abcde" "abcdE")))
 
68
 
 
69
(deftest nstring-upcase.11
 
70
  :notes (:nil-vectors-are-strings)
 
71
  (nstring-upcase (make-array '(0) :element-type nil))
 
72
  "")
 
73
 
 
74
(deftest nstring-upcase.order.1
 
75
  (let ((i 0) a b c (s (copy-seq "abcdef")))
 
76
    (values
 
77
     (nstring-upcase
 
78
      (progn (setf a (incf i)) s)
 
79
      :start (progn (setf b (incf i)) 1)
 
80
      :end   (progn (setf c (incf i)) 4))
 
81
     i a b c))
 
82
  "aBCDef" 3 1 2 3)
 
83
 
 
84
(deftest nstring-upcase.order.2
 
85
  (let ((i 0) a b c (s (copy-seq "abcdef")))
 
86
    (values
 
87
     (nstring-upcase
 
88
      (progn (setf a (incf i)) s)
 
89
      :end   (progn (setf b (incf i)) 4)
 
90
      :start (progn (setf c (incf i)) 1))
 
91
     i a b c))
 
92
  "aBCDef" 3 1 2 3)
 
93
 
 
94
  
 
95
;;; Error cases
 
96
 
 
97
(deftest nstring-upcase.error.1
 
98
  (signals-error (nstring-upcase) program-error)
 
99
  t)
 
100
 
 
101
(deftest nstring-upcase.error.2
 
102
  (signals-error (nstring-upcase (copy-seq "abc") :bad t) program-error)
 
103
  t)
 
104
 
 
105
(deftest nstring-upcase.error.3
 
106
  (signals-error (nstring-upcase (copy-seq "abc") :start) program-error)
 
107
  t)
 
108
 
 
109
(deftest nstring-upcase.error.4
 
110
  (signals-error (nstring-upcase (copy-seq "abc") :bad t
 
111
                                      :allow-other-keys nil)
 
112
                 program-error)
 
113
  t)
 
114
 
 
115
(deftest nstring-upcase.error.5
 
116
  (signals-error (nstring-upcase (copy-seq "abc") :end) program-error)
 
117
  t)
 
118
 
 
119
(deftest nstring-upcase.error.6
 
120
  (signals-error (nstring-upcase (copy-seq "abc") 1 2) program-error)
 
121
  t)
 
122