X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Fcompress.lisp;h=3a6877434d031a9a358297ba2126e2cc47060262;hb=5adb58ea9a2b4f0af8789ce6ac722253e1aa6153;hp=02c8cd292fe5500a655f48bff9ee87c368856a47;hpb=35ddd15fad42a60b445284900020d5b5a7edad8c;p=uffi.git diff --git a/tests/compress.lisp b/tests/compress.lisp index 02c8cd2..3a68774 100644 --- a/tests/compress.lisp +++ b/tests/compress.lisp @@ -2,12 +2,12 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Name: compress.cl +;;;; Name: compress.lisp ;;;; Purpose: UFFI Example file for zlib compression -;;;; Programmer: Kevin M. Rosenberg +;;;; Author: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: compress.lisp,v 1.4 2003/03/10 17:37:05 kevin Exp $ +;;;; $Id: compress.lisp,v 1.11 2003/05/02 02:50:12 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -16,22 +16,8 @@ ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* -(in-package :cl-user) +(in-package :uffi-tests) -(eval-when (:load-toplevel :execute) - (unless (uffi:load-foreign-library - #-(or macosx darwin) - (uffi:find-foreign-library - "libz" - '("/usr/local/lib/" "/usr/lib/" "/zlib/") - :types '("so" "a")) - #+(or macosx darwin) - (uffi:find-foreign-library "z" - `(,(pathname-directory *load-pathname*))) - :module "zlib" - :supporting-libraries '("c")) - (warn "Unable to load zlib"))) - (uffi:def-function ("compress" c-compress) ((dest (* :unsigned-char)) (destlen (* :long)) @@ -91,29 +77,21 @@ (uffi:free-foreign-object destlen) (uffi:free-foreign-object dest))))))) -#+examples-uffi -(progn - (flet ((print-results (str) - (multiple-value-bind (compressed len) (compress str) - (let ((*print-length* nil)) - (format t "~&(compress ~S) => " str) - (format t "~S~%" (map 'list #'char-code compressed)))))) - (print-results "") - (print-results "test") - (print-results "test2"))) +(deftest compress.1 (map 'list #'char-code (compress "")) + (120 156 3 0 0 0 0 1)) +(deftest compress.2 (map 'list #'char-code (compress "test")) + (120 156 43 73 45 46 1 0 4 93 1 193)) +(deftest compress.3 (map 'list #'char-code (compress "test2")) + (120 156 43 73 45 46 49 2 0 6 80 1 243)) + +(defun compress-uncompress (str) + (multiple-value-bind (compressed len) (compress str) + (declare (ignore len)) + (multiple-value-bind (uncompressed len2) (uncompress compressed) + (declare (ignore len2)) + uncompressed))) -#+test-uffi -(progn - (flet ((test-compress (str) - (multiple-value-bind (compressed len) (compress str) - (multiple-value-bind (uncompressed len2) (uncompress compressed) - (util.test:test str uncompressed :test #'string= - :fail-info "Error uncompressing a compressed string"))))) - (test-compress "") - (test-compress "test") - (test-compress "test2"))) -;; Results of the above on my system: -;; (compress "") => 789c300001,8 -;; (compress "test") => 789c2b492d2e1045d1c1,12 -;; (compress "test2") => 789c2b492d2e31206501f3,13 +(deftest uncompress.1 "" "") +(deftest uncompress.2 "test" "test") +(deftest uncompress.3 "test2" "test2")