Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • tests/sets.lisp
    1
    +;; Tests for sets
    
    2
    +
    
    3
    +(defpackage :sets-tests
    
    4
    +  (:use :cl :lisp-unit))
    
    5
    +
    
    6
    +(in-package "SETS-TESTS")
    
    7
    +
    
    8
    +(define-test set-diff.hash-eql
    
    9
    +    (:tag :issues)
    
    10
    +  ;; For set-difference to use hashtables by making the threshold
    
    11
    +  ;; small.
    
    12
    +  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    13
    +    (assert-equal '(2 2 1)
    
    14
    +		  (set-difference '(1 2 2 3) '(3 4)))
    
    15
    +    (assert-equal '(1 2 2)
    
    16
    +		  (set-difference '(1 2 2 3) '(3 4 5 6 7 8)))
    
    17
    +    (assert-equal '(2 2 1)
    
    18
    +		  (set-difference '(1 2 2 3) '(3 4)
    
    19
    +				  :test #'eql))
    
    20
    +    (assert-equal '(1 2 2)
    
    21
    +		  (set-difference '(1 2 2 3) '(3 4 5 6 7 8)
    
    22
    +				  :test #'eql))))
    
    23
    +
    
    24
    +(define-test set-diff.hash-eq
    
    25
    +    (:tag :issues)
    
    26
    +  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    27
    +    (assert-equal '(b b a)
    
    28
    +		  (set-difference '(a b b c) '(c d e) :test 'eq))
    
    29
    +    (assert-equal '(a b b)
    
    30
    +		  (set-difference '(a b b c) '(c d e f g h) :test 'eq))
    
    31
    +    (assert-equal '(b b a)
    
    32
    +		  (set-difference '(a b b c) '(c d e) :test #'eq))
    
    33
    +    (assert-equal '(a b b)
    
    34
    +		  (set-difference '(a b b c) '(c d e f g h) :test #'eq))))
    
    35
    +
    
    36
    +(define-test set-diff.hash-equal
    
    37
    +    (:tag :issues)
    
    38
    +  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    39
    +    (assert-equal '("b" "b" "a")
    
    40
    +		  (set-difference '("a" "b" "b" "c")
    
    41
    +				  '("c" "d" "e")
    
    42
    +				  :test 'equal))
    
    43
    +    (assert-equal '("a" "b" "b")
    
    44
    +		  (set-difference '("a" "b" "b" "c")
    
    45
    +				  '("c" "d" "e" "f" "g" "h")
    
    46
    +				  :test 'equal))
    
    47
    +    (assert-equal '("b" "b" "a")
    
    48
    +		  (set-difference '("a" "b" "b" "c")
    
    49
    +				  '("c" "d" "e")
    
    50
    +				  :test #'equal))
    
    51
    +    (assert-equal '("a" "b" "b")
    
    52
    +		  (set-difference '("a" "b" "b" "c")
    
    53
    +				  '("c" "d" "e" "f" "g" "h")
    
    54
    +				  :test #'equal))))
    
    55
    +
    
    56
    +(define-test set-diff.hash-equalp
    
    57
    +    (:tag :issues)
    
    58
    +  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    59
    +    (assert-equal '("b" "b" "a")
    
    60
    +		  (set-difference '("a" "b" "b" "c")
    
    61
    +				  '("C" "d" "e")
    
    62
    +				  :test 'equalp))
    
    63
    +    (assert-equal '("a" "b" "b")
    
    64
    +		  (set-difference '("a" "b" "b" "C")
    
    65
    +				  '("c" "D" "e" "f" "g" "h")
    
    66
    +				  :test 'equalp))
    
    67
    +    (assert-equal '("b" "b" "a")
    
    68
    +		  (set-difference '("a" "b" "b" "c")
    
    69
    +				  '("C" "d" "e")
    
    70
    +				  :test #'equalp))
    
    71
    +    (assert-equal '("a" "b" "b")
    
    72
    +		  (set-difference '("a" "b" "b" "C")
    
    73
    +				  '("c" "D" "e" "f" "g" "h")
    
    74
    +				  :test #'equalp))))