integer-length.lsp 1.53 KB
Newer Older
1 2 3 4 5 6 7 8
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Sep  7 10:10:10 2003
;;;; Contains: Tests for INTEGER-LENGTH

(in-package :cl-test)

(deftest integer-length.error.1
9 10
  (signals-error (integer-length) program-error)
  t)
11 12

(deftest integer-length.error.2
13 14
  (signals-error (integer-length 1 1) program-error)
  t)
15 16

(deftest integer-length.error.3
17 18
  (signals-error (integer-length 1 nil) program-error)
  t)
19 20

(deftest integer-length.error.4
21
  (check-type-error #'integer-length #'integerp)
22 23 24 25
  nil)

(deftest integer-length.1
  (loop for len from 0 to 100
sds's avatar
sds committed
26 27 28 29 30
        for i = (1- (ash 1 len))
        for vals = (multiple-value-list (integer-length i))
        for len2 = (car vals)
        always (and (= (length vals) 1)
                    (eql len len2)))
31 32 33 34
  t)

(deftest integer-length.2
  (loop for len from 0 to 100
sds's avatar
sds committed
35 36 37 38 39
        for i = (ash 1 len)
        for vals = (multiple-value-list (integer-length i))
        for len2 = (car vals)
        always (and (= (length vals) 1)
                    (eql (1+ len) len2)))
40 41 42 43
  t)

(deftest integer-length.3
  (loop for len from 0 to 100
sds's avatar
sds committed
44 45 46 47 48
        for i = (- (ash 1 len))
        for vals = (multiple-value-list (integer-length i))
        for len2 = (car vals)
        always (and (= (length vals) 1)
                    (eql len len2)))
49 50 51 52
  t)

(deftest integer-length.4
  (loop for len from 0 to 100
sds's avatar
sds committed
53 54 55 56 57
        for i = (- -1 (ash 1 len))
        for vals = (multiple-value-list (integer-length i))
        for len2 = (car vals)
        always (and (= (length vals) 1)
                    (eql (1+ len) len2)))
58
  t)