logtest.lsp 1021 Bytes
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Sep 11 23:22:46 2003
;;;; Contains: Tests for LOGTEST

(in-package :cl-test)

8 9
;;; Error tests

10
(deftest logtest.error.1
11 12
  (signals-error (logtest) program-error)
  t)
13 14

(deftest logtest.error.2
15 16
  (signals-error (logtest 0) program-error)
  t)
17 18

(deftest logtest.error.3
19 20
  (signals-error (logtest 0 0 nil) program-error)
  t)
21 22

(deftest logtest.error.4
pfdietz's avatar
pfdietz committed
23
  (check-type-error #'(lambda (x) (logtest x -1)) #'integerp)
24 25 26
  nil)

(deftest logtest.error.5
pfdietz's avatar
pfdietz committed
27
  (check-type-error #'(lambda (x) (logtest -1 x)) #'integerp)
28 29
  nil)

30 31
;;; Non-error tests

32 33
(deftest logtest.1
  (loop for x = (logand (random-fixnum) (random-fixnum))
sds's avatar
sds committed
34 35 36 37 38 39
        for y = (logand (random-fixnum) (random-fixnum))
        repeat 10000
        unless (if (logtest x y)
                   (not (zerop (logand x y)))
                 (zerop (logand x y)))
        collect (list x y))
40 41 42 43 44 45 46 47 48 49
  nil)

(deftest logtest.2
  (logtest 1 2)
  nil)

(deftest logtest.3
  (notnot-mv (logtest 8 (logior 8 4)))
  t)

sds's avatar
sds committed
50 51