source: trunk/source/tests/ansi-tests/parse-namestring.lsp @ 8991

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

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

File size: 2.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Aug 14 13:59:18 2004
4;;;; Contains: Tests of PARSE-NAMESTRING
5
6(in-package :cl-test)
7
8;;; "Parsing a null string always succeeds, producing a pathname
9;;;  with all components (except the host) equal to nil."
10
11(deftest parse-namestring.1
12  (let ((vals (multiple-value-list (parse-namestring ""))))
13    (assert (= (length vals) 2))
14    (let ((pn (first vals))
15          (pos (second vals)))
16      (values
17       (pathname-directory pn)
18       (pathname-device pn)
19       (pathname-name pn)
20       (pathname-type pn)
21       (pathname-version pn)
22       pos)))
23  nil nil nil nil nil 0)
24
25(deftest parse-namestring.2
26  (let ((vals (multiple-value-list (parse-namestring (make-array 0 :element-type 'base-char)))))
27    (assert (= (length vals) 2))
28    (let ((pn (first vals))
29          (pos (second vals)))
30      (values
31       (pathname-directory pn)
32       (pathname-device pn)
33       (pathname-name pn)
34       (pathname-type pn)
35       (pathname-version pn)
36       pos)))
37  nil nil nil nil nil 0)
38
39(deftest parse-namestring.3
40  (let ((vals (multiple-value-list (parse-namestring (make-array 4 :element-type 'base-char
41                                                                 :initial-element #\X
42                                                                 :fill-pointer 0)))))
43    (assert (= (length vals) 2))
44    (let ((pn (first vals))
45          (pos (second vals)))
46      (values
47       (pathname-directory pn)
48       (pathname-device pn)
49       (pathname-name pn)
50       (pathname-type pn)
51       (pathname-version pn)
52       pos)))
53  nil nil nil nil nil 0)
54
55(deftest parse-namestring.4
56  (loop for etype in '(standard-char base-char character)
57        for s0 = (make-array 4 :element-type etype :initial-element #\X)
58        for s = (make-array 0 :element-type etype :displaced-to s0
59                            :displaced-index-offset 1)
60        for vals = (multiple-value-list (parse-namestring s))
61        for pn = (first vals)
62        for pos = (second vals)
63        do (assert (= (length vals) 2))
64        nconc
65        (let ((result (list (pathname-directory pn)
66                            (pathname-device pn)
67                            (pathname-name pn)
68                            (pathname-type pn)
69                            (pathname-version pn)
70                            pos)))
71          (unless (equal result '(nil nil nil nil nil 0))
72            (list (list etype result)))))
73  nil)
74
75;;; Error tests
76
77(deftest parse-namestring.error.1
78  (signals-error (parse-namestring) program-error)
79  t)
80
81(deftest parse-name-string.error.2
82  (signals-error (parse-namestring "" nil *default-pathname-defaults* :foo nil) program-error)
83  t)
84
85(deftest parse-name-string.error.3
86  (signals-error (parse-namestring "" nil *default-pathname-defaults* :start) program-error)
87  t)
88
89
Note: See TracBrowser for help on using the repository browser.