From 7c64d23b0af1f33292fa47f9201ad42bb984af60 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 21 Feb 2025 14:06:05 +0000 Subject: Add unit tests for lib.functions.remove-at-indices --- tests/functions.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/functions.lisp') diff --git a/tests/functions.lisp b/tests/functions.lisp index b629c1f..ac8599d 100644 --- a/tests/functions.lisp +++ b/tests/functions.lisp @@ -93,3 +93,22 @@ (is equal 3 (->> (assoc #\t res) cdr length)) (is equal 2 (->> (assoc #\space res) cdr length)) (is equal 2 (->> (assoc #\s res) cdr length)))) + +(define-test (function-test remove-at-indices) + :depends-on (range) + :compile-at :execute + (fail (remove-at-indices "a string" "another string")) + (true (null (remove-at-indices nil nil))) + (is equal '(1 2 3) (remove-at-indices nil '(1 2 3))) + (is equal '(2) (remove-at-indices '(0 2) '(1 2 3))) + (let* ((inp (range 100 200)) + (t1 (remove-at-indices (range 0 100 2) inp)) + (t2 (remove-at-indices (range 1 100 2) inp))) + (is equal 50 (length t1)) + (is equal 50 (length t2)) + (true (every (lambda (n) (not (member n t2))) t1)) + (true (every (lambda (n) (not (member n t1))) t2))) + (let* ((indices (list 0 5 6 7 8 9 10)) + (str-lst (remove-at-indices indices "Hello World")) + (ret (coerce str-lst 'string))) + (is string= "ello" ret))) -- cgit v1.2.3-13-gbd6f