[Git][cmucl/cmucl][issue-240-set-diff-with-hash-table] Add some simple set-difference tests with hashtables.
Raymond Toy (@rtoy)
gitlab at common-lisp.net
Tue Jun 20 01:13:04 UTC 2023
Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits:
28aafe04 by Raymond Toy at 2023-06-19T18:12:15-07:00
Add some simple set-difference tests with hashtables.
- - - - -
1 changed file:
- + tests/sets.lisp
Changes:
=====================================
tests/sets.lisp
=====================================
@@ -0,0 +1,74 @@
+;; Tests for sets
+
+(defpackage :sets-tests
+ (:use :cl :lisp-unit))
+
+(in-package "SETS-TESTS")
+
+(define-test set-diff.hash-eql
+ (:tag :issues)
+ ;; For set-difference to use hashtables by making the threshold
+ ;; small.
+ (let ((lisp::*min-list-length-for-hashtable* 2))
+ (assert-equal '(2 2 1)
+ (set-difference '(1 2 2 3) '(3 4)))
+ (assert-equal '(1 2 2)
+ (set-difference '(1 2 2 3) '(3 4 5 6 7 8)))
+ (assert-equal '(2 2 1)
+ (set-difference '(1 2 2 3) '(3 4)
+ :test #'eql))
+ (assert-equal '(1 2 2)
+ (set-difference '(1 2 2 3) '(3 4 5 6 7 8)
+ :test #'eql))))
+
+(define-test set-diff.hash-eq
+ (:tag :issues)
+ (let ((lisp::*min-list-length-for-hashtable* 2))
+ (assert-equal '(b b a)
+ (set-difference '(a b b c) '(c d e) :test 'eq))
+ (assert-equal '(a b b)
+ (set-difference '(a b b c) '(c d e f g h) :test 'eq))
+ (assert-equal '(b b a)
+ (set-difference '(a b b c) '(c d e) :test #'eq))
+ (assert-equal '(a b b)
+ (set-difference '(a b b c) '(c d e f g h) :test #'eq))))
+
+(define-test set-diff.hash-equal
+ (:tag :issues)
+ (let ((lisp::*min-list-length-for-hashtable* 2))
+ (assert-equal '("b" "b" "a")
+ (set-difference '("a" "b" "b" "c")
+ '("c" "d" "e")
+ :test 'equal))
+ (assert-equal '("a" "b" "b")
+ (set-difference '("a" "b" "b" "c")
+ '("c" "d" "e" "f" "g" "h")
+ :test 'equal))
+ (assert-equal '("b" "b" "a")
+ (set-difference '("a" "b" "b" "c")
+ '("c" "d" "e")
+ :test #'equal))
+ (assert-equal '("a" "b" "b")
+ (set-difference '("a" "b" "b" "c")
+ '("c" "d" "e" "f" "g" "h")
+ :test #'equal))))
+
+(define-test set-diff.hash-equalp
+ (:tag :issues)
+ (let ((lisp::*min-list-length-for-hashtable* 2))
+ (assert-equal '("b" "b" "a")
+ (set-difference '("a" "b" "b" "c")
+ '("C" "d" "e")
+ :test 'equalp))
+ (assert-equal '("a" "b" "b")
+ (set-difference '("a" "b" "b" "C")
+ '("c" "D" "e" "f" "g" "h")
+ :test 'equalp))
+ (assert-equal '("b" "b" "a")
+ (set-difference '("a" "b" "b" "c")
+ '("C" "d" "e")
+ :test #'equalp))
+ (assert-equal '("a" "b" "b")
+ (set-difference '("a" "b" "b" "C")
+ '("c" "D" "e" "f" "g" "h")
+ :test #'equalp))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/28aafe047bc4bf7ee9485c979b423e92a8dc304d
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/28aafe047bc4bf7ee9485c979b423e92a8dc304d
You're receiving this email because of your account on gitlab.common-lisp.net.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20230620/cbdd51c3/attachment-0001.html>
More information about the cmucl-cvs
mailing list