r5589: Auto commit for Debian build
[uffi.git] / tests / compress.lisp
index 02c8cd292fe5500a655f48bff9ee87c368856a47..5bb6e3d05f7e5fc129d6472b3ce107d458ea853b 100644 (file)
@@ -2,36 +2,19 @@
 ;;;; *************************************************************************\r
 ;;;; FILE IDENTIFICATION\r
 ;;;;\r
-;;;; Name:          compress.cl\r
+;;;; Name:          compress.lisp\r
 ;;;; Purpose:       UFFI Example file for zlib compression\r
-;;;; Programmer:    Kevin M. Rosenberg\r
+;;;; Author:        Kevin M. Rosenberg\r
 ;;;; Date Started:  Feb 2002\r
 ;;;;\r
-;;;; $Id: compress.lisp,v 1.4 2003/03/10 17:37:05 kevin Exp $\r
+;;;; $Id: compress.lisp,v 1.12 2003/08/13 18:53:42 kevin Exp $\r
 ;;;;\r
-;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg\r
+;;;; This file, part of UFFI, is Copyright (c) 2002-2003 by Kevin M. Rosenberg\r
 ;;;;\r
-;;;; UFFI users are granted the rights to distribute and use this software\r
-;;;; as governed by the terms of the Lisp Lesser GNU Public License\r
-;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.\r
 ;;;; *************************************************************************\r
 \r
-(in-package :cl-user)\r
+(in-package #:uffi-tests)\r
 \r
-(eval-when (:load-toplevel :execute)\r
-  (unless (uffi:load-foreign-library\r
-          #-(or macosx darwin)\r
-          (uffi:find-foreign-library\r
-           "libz"\r
-           '("/usr/local/lib/" "/usr/lib/" "/zlib/")\r
-           :types '("so" "a"))\r
-          #+(or macosx darwin)\r
-          (uffi:find-foreign-library "z"\r
-                                     `(,(pathname-directory *load-pathname*)))\r
-          :module "zlib" \r
-          :supporting-libraries '("c"))\r
-    (warn "Unable to load zlib")))\r
-  \r
 (uffi:def-function ("compress" c-compress)\r
     ((dest (* :unsigned-char))\r
      (destlen (* :long))\r
            (uffi:free-foreign-object destlen)\r
            (uffi:free-foreign-object dest)))))))\r
 \r
-#+examples-uffi\r
-(progn\r
-  (flet ((print-results (str)\r
-          (multiple-value-bind (compressed len) (compress str)\r
-            (let ((*print-length* nil))\r
-              (format t "~&(compress ~S) => " str)\r
-              (format t "~S~%" (map 'list #'char-code compressed))))))\r
-    (print-results "")\r
-    (print-results "test")\r
-    (print-results "test2")))\r
+(deftest compress.1 (map 'list #'char-code (compress ""))\r
+  (120 156 3 0 0 0 0 1))\r
+(deftest compress.2 (map 'list #'char-code  (compress "test"))\r
+  (120 156 43 73 45 46 1 0 4 93 1 193))\r
+(deftest compress.3 (map 'list #'char-code (compress "test2"))\r
+  (120 156 43 73 45 46 49 2 0 6 80 1 243))\r
+\r
+(defun compress-uncompress (str)\r
+  (multiple-value-bind (compressed len) (compress str)\r
+    (declare (ignore len))\r
+    (multiple-value-bind (uncompressed len2) (uncompress compressed)\r
+      (declare (ignore len2))\r
+      uncompressed)))\r
 \r
-#+test-uffi\r
-(progn\r
-  (flet ((test-compress (str)\r
-          (multiple-value-bind (compressed len) (compress str)\r
-            (multiple-value-bind (uncompressed len2) (uncompress compressed)\r
-              (util.test:test str uncompressed :test #'string=\r
-                              :fail-info "Error uncompressing a compressed string")))))\r
-    (test-compress "")\r
-    (test-compress "test")\r
-    (test-compress "test2")))\r
 \r
-;; Results of the above on my system:\r
-;; (compress "") => 789c300001,8\r
-;; (compress "test") => 789c2b492d2e1045d1c1,12\r
-;; (compress "test2") => 789c2b492d2e31206501f3,13\r
+(deftest uncompress.1 "" "")\r
+(deftest uncompress.2 "test" "test")\r
+(deftest uncompress.3 "test2" "test2")\r