Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ansi-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michał Herda
ansi-test
Commits
7dfa9b27
Commit
7dfa9b27
authored
21 years ago
by
pfdietz
Browse files
Options
Downloads
Patches
Plain Diff
More file-position tests.
parent
876986b4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ansi-tests/file-position.lsp
+108
-0
108 additions, 0 deletions
ansi-tests/file-position.lsp
with
108 additions
and
0 deletions
ansi-tests/file-position.lsp
+
108
−
0
View file @
7dfa9b27
...
@@ -36,3 +36,111 @@
...
@@ -36,3 +36,111 @@
(notnot (> (file-position is) 0))))
(notnot (> (file-position is) 0))))
0 #\; t)
0 #\; t)
(deftest file-position.5
(with-open-file
(os "tmp.dat":direction :output
:if-exists :supersede)
(values
(file-position os)
(write-char #\x os)
(notnot (> (file-position os) 0))))
0 #\x t)
(deftest file-position.6
(with-open-file
(os "tmp.dat":direction :output
:if-exists :supersede)
(let ((p1 (file-position os))
(delta (file-string-length os #\x)))
(write-char #\x os)
(let ((p2 (file-position os)))
(or (null p1) (null p2) (null delta)
(=t (+ p1 delta) p2)))))
t)
;;; Byte streams
(deftest file-position.7
(loop for len from 1 to 32
for n = (ash 1 len)
do (with-open-file
(os "tmp.dat" :direction :output
:if-exists :supersede
:element-type `(unsigned-byte ,len))
(loop for i from 0 below 100
for r = (logand (1- n) i)
for pos = (file-position os)
do (assert (or (not pos) (eql pos i)))
do (write-byte r os)))
do (with-open-file
(is "tmp.dat" :direction :input
:element-type `(unsigned-byte ,len))
(loop for i from 0 below 100
for pos = (file-position is)
do (assert (or (not pos) (eql pos i)))
do (let ((byte (read-byte is)))
(assert (eql byte (logand (1- n) i)))))))
nil)
(deftest file-position.8
(loop for len from 33 to 100
for n = (ash 1 len)
do (with-open-file
(os "tmp.dat" :direction :output
:if-exists :supersede
:element-type `(unsigned-byte ,len))
(loop for i from 0 below 100
for r = (logand (1- n) i)
for pos = (file-position os)
do (assert (or (not pos) (eql pos i)))
do (write-byte r os)))
do (with-open-file
(is "tmp.dat" :direction :input
:element-type `(unsigned-byte ,len))
(loop for i from 0 below 100
for pos = (file-position is)
do (assert (or (not pos) (eql pos i)))
do (let ((byte (read-byte is)))
(assert (eql byte (logand (1- n) i)))))))
nil)
;;; Error tests
(deftest file-position.error.1
(signals-error (file-position) program-error)
t)
(deftest file-position.error.2
(signals-error
(file-position (make-string-input-stream "abc") :start nil)
program-error)
t)
;;; It's not clear what 'too large' means -- can we set the
;;; file position to a point where the file may later be extended
;;; by some other writer?
#|
(deftest file-position.error.3
(signals-error
(with-open-file
(is "file-position.lsp" :direction :input)
(flet ((%fail () (error 'type-error)))
(unless (file-position is :end) (%fail))
(let ((fp (file-position is)))
(unless fp (%fail))
(file-position is (+ 1000000 fp)))))
error)
t)
(deftest file-position.error.4
(signals-error
(with-open-file
(is "file-position.lsp" :direction :input)
(file-position is 1000000000000000000000))
error)
t)
|#
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment