Common Lisp Package: FLEXI-STREAMS-TEST

README:

FUNCTION

Public

RUN-ALL-TESTS (&KEY VERBOSE)

Runs all tests for FLEXI-STREAMS and returns a true value iff all tests succeeded. VERBOSE is interpreted by the individual test suites above.

Private

ACCEPT-OVERLONG (OCTETS CODE-POINT)

Converts the `overlong' UTF-8 sequence OCTETS to using OCTETS-TO-STRINGS, accepts the expected error with the corresponding restart and checks that the result is CODE-POINT.

COMPARE-FILES (&KEY VERBOSE)

Each test in this suite copies the contents of one file (in the `test' directory) to another file (in a temporary directory) using flexi streams with different external formats. The resulting file is compared with an existing file in the `test' directory to check if the outcome is as expected. Uses various variants of the :DIRECTION keyword when opening the files. Returns a true value iff all tests succeeded. Prints information about each individual comparison if VERBOSE is true.

COPY-FILE (PATH-IN EXTERNAL-FORMAT-IN PATH-OUT EXTERNAL-FORMAT-OUT DIRECTION-OUT DIRECTION-IN)

Copies the contents of the file denoted by the pathname PATH-IN to the file denoted by the pathname PATH-OUT using flexi streams - STREAM-IN is read with the external format EXTERNAL-FORMAT-IN and STREAM-OUT is written with EXTERNAL-FORMAT-OUT. The input file is opened with the :DIRECTION keyword argument DIRECTION-IN, the output file is opened with the :DIRECTION keyword argument DIRECTION-OUT.

COPY-STREAM (STREAM-IN EXTERNAL-FORMAT-IN STREAM-OUT EXTERNAL-FORMAT-OUT)

Copies the contents of the binary stream STREAM-IN to the binary stream STREAM-OUT using flexi streams - STREAM-IN is read with the external format EXTERNAL-FORMAT-IN and STREAM-OUT is written with EXTERNAL-FORMAT-OUT.

COPY-STREAM* (STREAM-IN EXTERNAL-FORMAT-IN STREAM-OUT EXTERNAL-FORMAT-OUT)

Like COPY-STREAM, but uses READ-SEQUENCE and WRITE-SEQUENCE instead of READ-LINE and WRITE-LINE.

CREATE-FILE-VARIANTS (FILE-NAME SYMBOL)

For a name suffix FILE-NAME and a symbol SYMBOL denoting an encoding returns a list of pairs where the car is a full file name and the cdr is the corresponding external format. This list contains all possible variants w.r.t. to line-end conversion and endianness.

CREATE-TEST-COMBINATIONS (FILE-NAME SYMBOLS &OPTIONAL SIMPLEP)

For a name suffix FILE-NAME and a list of symbols SYMBOLS denoting different encodings of the corresponding file returns a list of lists which can be used as arglists by COMPARE-FILES. If SIMPLEP is true, a list which can be used for the string and sequence tests below is returned.

ERROR-HANDLING-TESTS (&KEY VERBOSE)

Tests several possible errors and how they are handled.

FILE-AS-OCTET-VECTOR (PATHSPEC)

Returns the contents of the file denoted by PATHSPEC as a vector of octets.

FILE-AS-STRING (PATHSPEC EXTERNAL-FORMAT)

Reads the contents of the file denoted by PATHSPEC using the external format EXTERNAL-FORMAT and returns the result as a string.

FILE-EQUAL (FILE1 FILE2)

Returns a true value iff FILE1 and FILE2 have the same contents (viewed as binary files).

NORMALIZE-EXTERNAL-FORMAT (EXTERNAL-FORMAT)

Returns a list which is a `normalized' representation of the external format EXTERNAL-FORMAT. Used internally by PRINT-OBJECT, for example. Basically, the result is an argument list that can be fed back to MAKE-EXTERNAL-FORMAT to create an equivalent object.

OLD-OCTETS-TO-STRING (VECTOR &KEY (EXTERNAL-FORMAT (MAKE-EXTERNAL-FORMAT LATIN1)) (START 0) (END (LENGTH VECTOR)))

The old version of OCTETS-TO-STRING. We can use it to test in-memory streams.

OLD-STRING-TO-OCTETS (STRING &KEY (EXTERNAL-FORMAT (MAKE-EXTERNAL-FORMAT LATIN1)) (START 0) END)

The old version of STRING-TO-OCTETS. We can use it to test in-memory streams.

READ-FLEXI-LINE (SEQUENCE EXTERNAL-FORMAT)

Creates and returns a string from the octet sequence SEQUENCE using the external format EXTERNAL-FORMAT.

READ-FLEXI-LINE* (SEQUENCE EXTERNAL-FORMAT)

Like READ-FLEXI-LINE but uses OCTETS-TO-STRING internally.

SEQUENCE-EQUAL (SEQ1 SEQ2)

Whether the two sequences have the same elements.

SEQUENCE-TESTS (&KEY VERBOSE)

Several tests to confirm that READ-SEQUENCE and WRITE-SEQUENCE behave as expected.

STRING-TESTS (&KEY VERBOSE)

Tests whether conversion from strings to octets and vice versa works as expected. Also tests with the old versions of the conversion functions in order to test in-memory streams.

UNREAD-CHAR-TESTS (&KEY VERBOSE)

Tests whether UNREAD-CHAR behaves as expected.

MACRO

Private

USING-VALUES ((&REST VALUES) &BODY BODY)

Executes BODY and feeds an element from VALUES to the USE-VALUE restart each time a EXTERNAL-FORMAT-ENCODING-ERROR is signalled. Signals an error when there are more or less EXTERNAL-FORMAT-ENCODING-ERRORs than there are elements in VALUES.

WITH-REBINDING (BINDINGS &BODY BODY)

WITH-REBINDING ( { var | (var prefix) }* ) form* Evaluates a series of forms in the lexical environment that is formed by adding the binding of each VAR to a fresh, uninterned symbol, and the binding of that fresh, uninterned symbol to VAR's original value, i.e., its value in the current lexical environment. The uninterned symbol is created as if by a call to GENSYM with the string denoted by PREFIX - or, if PREFIX is not supplied, the string denoted by VAR - as argument. The forms are evaluated in order, and the values of all but the last are discarded (that is, the body is an implicit PROGN).

WITH-TEST-SUITE ((TEST-DESCRIPTION &KEY SHOW-PROGRESS-P) &BODY BODY)

Defines a test suite. Three utilities are available inside of the body of the macro: The function FAIL, and the macros CHECK and WITH-EXPECTED-ERROR. FAIL, the lowest level utility, marks the test defined by WITH-TEST-SUITE as failed. CHECK checks whether its argument is true, otherwise it calls FAIL. If during evaluation of the specified expression any condition is signalled, this is also considered a failure. WITH-EXPECTED-ERROR executes its body and considers the test a success if the specified error was signalled, otherwise it calls FAIL. WITH-TEST-SUITE prints a simple progress report if SHOW-PROGRESS-P is true.

WITH-UNIQUE-NAMES ((&REST BINDINGS) &BODY BODY)

Syntax: WITH-UNIQUE-NAMES ( { var | (var x) }* ) declaration* form* Executes a series of forms with each VAR bound to a fresh, uninterned symbol. The uninterned symbol is as if returned by a call to GENSYM with the string denoted by X - or, if X is not supplied, the string denoted by VAR - as argument. The variable bindings created are lexical unless special declarations are specified. The scopes of the name bindings and declarations do not include the Xs. The forms are evaluated in order, and the values of all but the last are discarded (that is, the body is an implicit PROGN).

VARIABLE

Private

*COPY-FUNCTION*

Which function to use when copying from one stream to the other - see for example COPY-FILE below.

*TEST-FILES*

A list of test files where each entry consists of the name prefix and a list of encodings.

*THIS-FILE*

The pathname of the file (`test.lisp') where this variable was defined.

*TMP-DIR*

The pathname of a temporary directory used for testing.

CONSTANT

Private

+BUFFER-SIZE+

Size of buffers for COPY-STREAM* below.