source: trunk/source/tests/ansi-tests/format-c.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 3.0 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jul 27 23:07:16 2004
4;;;; Contains: Tests of formatted output, ~C directive
5
6(in-package :cl-test)
7
8(compile-and-load "printer-aux.lsp")
9
10;;; Test of the ~C directive
11
12(deftest format.c.1
13  (loop for c across +standard-chars+
14        for s = (format nil "~C" c)
15        unless (string= s (string c))
16        collect (list c s))
17  nil)
18
19(deftest format.c.1a
20  (loop with count = 0
21        for i from 0 below (min #x10000 char-code-limit)
22        for c = (code-char i)
23        for s = (and c (format nil "~c" c))
24        unless (or (not c)
25                   (not (eql (char-code c) (char-int c)))
26                   (string= s (string c)))
27        do (incf count) and collect (list i c s)
28        when (> count 100) collect "count limit exceeded" and do (loop-finish))
29  nil)
30
31(deftest format.c.2
32  (loop for c across +standard-chars+
33        for s = (format nil "~:c" c)
34        unless (or (not (graphic-char-p c))
35                   (eql c #\Space)
36                   (string= s (string c)))
37        collect (list c s))
38  nil)
39
40(deftest format.c.2a
41  (loop with count = 0
42        for i from 0 below (min #x10000 char-code-limit)
43        for c = (code-char i)
44        for s = (and c (format nil "~:C" c))
45        unless (or (not c)
46                   (not (eql (char-code c) (char-int c)))
47                   (not (graphic-char-p c))
48                   (eql c #\Space)
49                   (string= s (string c)))
50        do (incf count) and collect (list i c s)
51        when (> count 100) collect "count limit exceeded" and do (loop-finish))
52  nil)
53
54(def-format-test format.c.3
55  "~:C" (#\Space) #.(char-name #\Space))
56
57(deftest format.c.4
58  (loop for c across +standard-chars+
59        for s = (format nil "~:C" c)
60        unless (or (graphic-char-p c)
61                   (string= s (char-name c)))
62        collect (list c (char-name c) s))
63  nil)
64
65(deftest format.c.4a
66  (loop with count = 0
67        for i from 0 below (min #x10000 char-code-limit)
68        for c = (code-char i)
69        for s = (and c (format nil "~:c" c))
70        unless (or (not c)
71                   (not (eql (char-code c) (char-int c)))
72                   (graphic-char-p c)
73                   (string= s (char-name c)))
74        do (incf count) and collect (print (list i c s))
75        when (> count 100) collect "count limit exceeded" and do (loop-finish))
76  nil)
77
78(deftest format.c.5
79  (loop for c across +standard-chars+
80        for s = (format nil "~@c" c)
81        for c2 = (read-from-string s)
82        unless (eql c c2)
83        collect (list c s c2))
84  nil)
85
86(deftest format.c.5a
87  (loop with count = 0
88        for i from 0 below (min #x10000 char-code-limit)
89        for c = (code-char i)
90        for s = (and c (format nil "~@C" c))
91        for c2 = (and c (read-from-string s))
92        unless (eql c c2)
93        do (incf count) and collect (list c s c2)
94        when (> count 100) collect "count limit exceeded" and do (loop-finish))
95  nil)
96
97(deftest format.c.6
98  (loop for c across +standard-chars+
99        for s1 = (format nil "~:C" c)
100        for s2 = (format nil "~:@C" c)
101        unless (eql (search s1 s2) 0)
102        collect (list c s1 s2))
103  nil)
104
105(deftest format.c.6a
106  (loop with count = 0
107        for i from 0 below (min #x10000 char-code-limit)
108        for c = (code-char i)
109        for s1 = (and c (format nil "~:C" c))
110        for s2 = (and c (format nil "~@:C" c))
111        unless (or (not c) (eql (search s1 s2) 0))
112        do (incf count) and collect (list c s1 s2)
113        when (> count 100) collect "count limit exceeded" and do (loop-finish))
114  nil)
115
116
117
Note: See TracBrowser for help on using the repository browser.