1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Package: rsm.bitcomp.test -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: bitcomp-test.lisp
;;;; Purpose: Regression testing for bit compression.
;;;; Author: R. Scott McIntire
;;;; Date Started: Aug 2003
;;;;
;;;; $Id: bitcomp-test.lisp,v 1.2 2003/10/04 14:47:16 rscottmcintire Exp $
;;;; *************************************************************************
(in-package #:cl-user)
(defpackage rsm.bitcomp.test
(:use #:cl #:ptester)
(:documentation
"Provides a test harness for bit compression code.")
)
(in-package rsm.bitcomp.test)
;;;; SET UP THE BIT COMPRESS DATA TO TEST.
(defparameter *b1* (rsm.bitcomp:make-compressed :list '(0 1 0 0 1 1 1 0 0 1)))
(defparameter *b2* (rsm.bitcomp:make-compressed :number 11))
(defparameter *b3* (rsm.bitcomp:make-compressed :list '(1 1 0 1)))
(defparameter *b4* (rsm.bitcomp:make-compressed :comp '((1 . 2) (2 . 3))))
(defparameter *b5* (rsm.bitcomp:make-compressed :comp '((1 . 4))))
;;;; RUN THE TESTS.
(defun run-bitcomp-tests ()
(with-tests (:name "BIT COMPRESSION TESTS")
(test (rsm.bitcomp:get-compressed-pairs *b2*)
(rsm.bitcomp:get-compressed-pairs *b3*)
:test #'equal
:fail-info "Test 1")
(test (rsm.bitcomp:get-compressed-pairs *b4*)
(rsm.bitcomp:get-compressed-pairs *b5*)
:test #'equal
:fail-info "Test 2")
(test '((2 . 1))
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:and *b1* *b2*))
:test #'equal
:fail-info "Test 3")
(test '((1 . 2) (4 . 4) (10 . 1))
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:or *b1* *b2*))
:test #'equal
:fail-info "Test 4")
(test '((1 . 1) (4 . 4) (10 . 1))
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:xor *b1* *b2*))
:test #'equal
:fail-info "Test 5")
(test '((1 . 2) (4 . 1))
(rsm.bitcomp:get-compressed-pairs *b2*)
:test #'equal
:fail-info "Test 6")
(test '((1 . 1) (3 . 2) (8 . 2) (11 . 2))
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:not 1 12 *b1*))
:test #'equal
:fail-info "Test 7")
(test nil
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:make-compressed
:rep (rsm.queue:create)))
:test #'equal
:fail-info "Test 8")
(test '((1 . 6) (10 . 2))
(rsm.bitcomp:get-compressed-pairs
(rsm.bitcomp:or
(rsm.bitcomp:make-compressed :comp '((1 . 3) (5 . 2)))
(rsm.bitcomp:make-compressed :comp '((4 . 2) (10 . 2)))))
:test #'equal
:fail-info "Test 9")
(test '((5 . 1))
(rsm.bitcomp:get-compressed-pairs
(rsm.bitcomp:and
(rsm.bitcomp:make-compressed :comp '((1 . 3) (5 . 2)))
(rsm.bitcomp:make-compressed :comp '((4 . 2) (10 . 2)))))
:test #'equal
:fail-info "Test 10")
(test '((1 . 4) (6 . 1) (10 . 2))
(rsm.bitcomp:get-compressed-pairs
(rsm.bitcomp:xor
(rsm.bitcomp:make-compressed :comp '((1 . 3) (5 . 2)))
(rsm.bitcomp:make-compressed :comp '((4 . 2) (10 . 2)))))
:test #'equal
:fail-info "Test 11")
(test '((0 . 2) (3 . 2) (8 . 2) (11 . 1))
(rsm.bitcomp:get-compressed-pairs
(rsm.bitcomp:not 0 11 (rsm.bitcomp:make-compressed
:list '(0 1 0 0 1 1 1 0 0 1))))
:test #'equal
:fail-info "Test 12")
(test nil
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:and *b1* *b2* *b4*))
:test #'equal
:fail-info "Test 13")
(test nil
(rsm.bitcomp:get-compressed-pairs (rsm.bitcomp:and *b1* *b4* *b2*))
:test #'equal
:fail-info "Test 14")
)
t
)
|