docs/test

svn: r13505
This commit is contained in:
Jay McCarthy 2009-02-09 17:48:04 +00:00
parent 767766521c
commit 0f96462369
4 changed files with 58 additions and 2 deletions

View File

@ -8,12 +8,14 @@
"mime-types-test.ss"
"url-param-test.ss"
"mod-map-test.ss"
"gzip-test.ss"
"util-test.ss")
(provide all-private-tests)
(define all-private-tests
(test-suite
"Internal"
gzip-tests
cache-table-tests
connection-manager-tests
define-closure-tests

View File

@ -0,0 +1,32 @@
#lang scheme
(require (planet "test.ss" ("schematics" "schemeunit.plt" 2))
web-server/private/gzip)
(provide gzip-tests)
(define gzip-tests
(test-suite
"GZip"
#;(test-case
"gzip/bytes"
(check-equal? (gzip/bytes #"1234567890")
#"\37\213\b\0\334k\220I\0\0033426153\267\2604\0\0\345\256\35&\n\0\0\0"))
(test-case
"gunzip/bytes"
(check-equal? (gunzip/bytes #"\37\213\b\0.k\220I\0\0033426153\267\2604\0\0\345\256\35&\n\0\0\0")
#"1234567890"))
(test-case
"identity"
(let* ([k (random 1000)]
[b (random 255)]
[bs (make-bytes k b)])
(check-equal? (gunzip/bytes (gzip/bytes bs))
bs)))
(test-case
"bad header"
(check-exn exn?
(lambda ()
(gunzip/bytes #"1234567890"))))))

View File

@ -367,6 +367,28 @@ with this process.
}
@; ------------------------------------------------------------
@section[#:tag "gzip.ss"]{GZip}
@(require (for-label web-server/private/gzip
file/gzip
file/gunzip))
@defmodule[web-server/private/gzip]{
The @web-server provides a thin wrapper around @schememodname[file/gzip] and @schememodname[file/gunzip].
@defproc[(gzip/bytes [ib bytes?])
bytes?]{
GZips @scheme[ib] and returns the result.
}
@defproc[(gunzip/bytes [ib bytes?])
bytes?]{
GUnzips @scheme[ib] and returns the result.
}
}
@; ------------------------------------------------------------
@section[#:tag "util.ss"]{Miscellaneous Utilities}
@(require (for-label web-server/private/util))

View File

@ -104,11 +104,11 @@ You can supply your own (built with these functions) when you write a stateless
@section{GZip Compression}
@(require (for-label file/gzip file/gunzip))
@(require (for-label file/gzip file/gunzip web-server/private/gzip))
@defmodule[web-server/stuffers/gzip]{
@defthing[gzip-stuffer (stuffer/c bytes? bytes?)]{
A @tech{stuffer} that uses @schememodname[file/gzip] and @schememodname[file/gunzip].
A @tech{stuffer} that uses @scheme[gzip/bytes] and @scheme[gunzip/bytes].
Note: You should probably compose this with @scheme[base64-stuffer] to get URL-safe bytes.
}