/[gcl]/gcl/ansi-tests/count-if.lsp
ViewVC logotype

Diff of /gcl/ansi-tests/count-if.lsp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pfdietz, Thu Oct 17 13:16:56 2002 UTC revision 1.3 by pfdietz, Mon Nov 4 04:31:48 2002 UTC
# Line 259  Line 259 
259              :end 7 :start 2 :from-end t)              :end 7 :start 2 :from-end t)
260    1)    1)
261    
262  ;;; tests on bitstrings  (deftest count-if-nonsimple-vector.17
263      (flet ((%f (x) (eqt x 'a)))
264        (let ((s (make-array 13 :initial-contents '(a b c d a e f a e f f a a)
265                             :fill-pointer 6)))
266          (values (count-if #'%f s)
267                  (count-if #'%f s :end nil)
268                  (count-if #'%f s :end 4)
269                  (count-if #'%f s :start 1)
270                  (count-if #'%f s :start 1 :end 4)
271                  (count-if #'%f s :start 1 :end 4 :from-end t))))
272      2 2 1 1 0 0)
273    
274  (deftest count-if-bitstring.1  ;;; tests on bit-vectors
275    
276    (deftest count-if-bit-vector.1
277    (count-if #'evenp #*001011101101)    (count-if #'evenp #*001011101101)
278    5)    5)
279    
280  (deftest count-if-bitstring.2  (deftest count-if-bit-vector.2
281    (count-if #'identity #*001011101101)    (count-if #'identity #*001011101101)
282    12)    12)
283    
284  (deftest count-if-bitstring.3  (deftest count-if-bit-vector.3
285    (count-if #'(lambda (x) (break)) #*)    (count-if #'(lambda (x) (break)) #*)
286    0)    0)
287    
288  (deftest count-if-bitstring.4  (deftest count-if-bit-vector.4
289    (count-if #'identity #*001011101101 :key #'zerop)    (count-if #'identity #*001011101101 :key #'zerop)
290    5)    5)
291    
292  (deftest count-if-bitstring.5  (deftest count-if-bit-vector.5
293    (count-if 'identity #*001011101101 :key #'zerop)    (count-if 'identity #*001011101101 :key #'zerop)
294    5)    5)
295    
296  (deftest count-if-bitstring.6  (deftest count-if-bit-vector.6
297    (count-if #'identity #*001011101101 :key 'zerop)    (count-if #'identity #*001011101101 :key 'zerop)
298    5)    5)
299    
300  (deftest count-if-bitstring.8  (deftest count-if-bit-vector.8
301    (count-if #'identity #*001011101101 :key 'oddp)    (count-if #'identity #*001011101101 :key 'oddp)
302    7)    7)
303    
304  (deftest count-if-bitstring.10  (deftest count-if-bit-vector.10
305    (count-if #'evenp #*001011101101 :key #'1+)    (count-if #'evenp #*001011101101 :key #'1+)
306    7)    7)
307    
308  (deftest count-if-bitstring.11  (deftest count-if-bit-vector.11
309    (let ((c 0))    (let ((c 0))
310      (count-if #'evenp #*001011101101      (count-if #'evenp #*001011101101
311                :key #'(lambda (x) (+ x (incf c)))))                :key #'(lambda (x) (+ x (incf c)))))
312    7)    7)
313    
314  (deftest count-if-bitstring.12  (deftest count-if-bit-vector.12
315    (let ((c 0))    (let ((c 0))
316      (count-if #'evenp #*001011101101      (count-if #'evenp #*001011101101
317                :from-end t                :from-end t
318                :key #'(lambda (x) (+ x (incf c)))))                :key #'(lambda (x) (+ x (incf c)))))
319    5)    5)
320    
321  (deftest count-if-bitstring.13  (deftest count-if-bit-vector.13
322    (count-if #'zerop #*0111011011100 :start 2)    (count-if #'zerop #*0111011011100 :start 2)
323    4)    4)
324    
325  (deftest count-if-bitstring.14  (deftest count-if-bit-vector.14
326    (count-if #'zerop #*0111011011100 :end 7)    (count-if #'zerop #*0111011011100 :end 7)
327    2)    2)
328        
329  (deftest count-if-bitstring.15  (deftest count-if-bit-vector.15
330    (count-if #'zerop #*0111011011100 :end 7 :start 2)    (count-if #'zerop #*0111011011100 :end 7 :start 2)
331    1)    1)
332        
333  (deftest count-if-bitstring.16  (deftest count-if-bit-vector.16
334    (count-if #'zerop #*0111011011100 :end 7 :start 2 :from-end t)    (count-if #'zerop #*0111011011100 :end 7 :start 2 :from-end t)
335    1)    1)
336    
337    (deftest count-if-bit-vector.17
338      (let ((s (make-array '(10) :initial-contents '(0 0 1 0 1 0 0 1 1 0)
339                           :element-type 'bit
340                           :fill-pointer 6)))
341        (values (count-if #'zerop s)
342                (count-if #'zerop s :end nil)
343                (count-if #'zerop s :end 4)
344                (count-if #'zerop s :start 5)
345                (count-if #'zerop s :start 1 :end 4)))
346      4 4 3 1 2)
347    
348  ;;; tests on strings  ;;; tests on strings
349    
350  (deftest count-if-string.1  (deftest count-if-string.1
# Line 382  Line 405 
405              "0111011011100" :end 7 :start 2 :from-end t)              "0111011011100" :end 7 :start 2 :from-end t)
406    1)    1)
407    
408    (deftest count-if-string.17
409      (let ((s (make-array '(10)
410                           :initial-contents (coerce "00a0aa0a0a" 'list)
411                           :element-type 'character
412                           :fill-pointer 6)))
413        (values (count-if #'digit-char-p s)
414                (count-if #'digit-char-p s :end nil)
415                (count-if #'digit-char-p s :start 1)
416                (count-if #'digit-char-p s :end 2)
417                (count-if #'digit-char-p s :start 1 :end 2)))
418      3 3 2 2 1)
419                
420  ;;; Error tests  ;;; Error tests
421    
422  (deftest count-if-error.1  (deftest count-if-error.1

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26