1 | ;-*- Mode: Lisp -*- |
---|

2 | ;;;; Author: Paul Dietz |
---|

3 | ;;;; Created: Sun Sep 7 10:10:10 2003 |
---|

4 | ;;;; Contains: Tests for INTEGER-LENGTH |
---|

5 | |
---|

6 | (in-package :cl-test) |
---|

7 | |
---|

8 | (deftest integer-length.error.1 |
---|

9 | (signals-error (integer-length) program-error) |
---|

10 | t) |
---|

11 | |
---|

12 | (deftest integer-length.error.2 |
---|

13 | (signals-error (integer-length 1 1) program-error) |
---|

14 | t) |
---|

15 | |
---|

16 | (deftest integer-length.error.3 |
---|

17 | (signals-error (integer-length 1 nil) program-error) |
---|

18 | t) |
---|

19 | |
---|

20 | (deftest integer-length.error.4 |
---|

21 | (check-type-error #'integer-length #'integerp) |
---|

22 | nil) |
---|

23 | |
---|

24 | (deftest integer-length.1 |
---|

25 | (loop for len from 0 to 100 |
---|

26 | for i = (1- (ash 1 len)) |
---|

27 | for vals = (multiple-value-list (integer-length i)) |
---|

28 | for len2 = (car vals) |
---|

29 | always (and (= (length vals) 1) |
---|

30 | (eql len len2))) |
---|

31 | t) |
---|

32 | |
---|

33 | (deftest integer-length.2 |
---|

34 | (loop for len from 0 to 100 |
---|

35 | for i = (ash 1 len) |
---|

36 | for vals = (multiple-value-list (integer-length i)) |
---|

37 | for len2 = (car vals) |
---|

38 | always (and (= (length vals) 1) |
---|

39 | (eql (1+ len) len2))) |
---|

40 | t) |
---|

41 | |
---|

42 | (deftest integer-length.3 |
---|

43 | (loop for len from 0 to 100 |
---|

44 | for i = (- (ash 1 len)) |
---|

45 | for vals = (multiple-value-list (integer-length i)) |
---|

46 | for len2 = (car vals) |
---|

47 | always (and (= (length vals) 1) |
---|

48 | (eql len len2))) |
---|

49 | t) |
---|

50 | |
---|

51 | (deftest integer-length.4 |
---|

52 | (loop for len from 0 to 100 |
---|

53 | for i = (- -1 (ash 1 len)) |
---|

54 | for vals = (multiple-value-list (integer-length i)) |
---|

55 | for len2 = (car vals) |
---|

56 | always (and (= (length vals) 1) |
---|

57 | (eql (1+ len) len2))) |
---|

58 | t) |
---|