r8005: Automated commit for kmrcl debian-version-1.58-1
[kmrcl.git] / tests.lisp
index d61d4391d7c939a3a204be8c6e2c0736414283a8..fc950e47ddf2a17d3b1ef979d29061332de9ad8f 100644 (file)
@@ -1,4 +1,4 @@
-;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: kmrcl-tests -*-
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2003
 ;;;;
-;;;; $Id: tests.lisp,v 1.17 2003/06/07 05:45:14 kevin Exp $
+;;;; $Id$
 ;;;;
 ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
 ;;;;
 (deftest str.24 (delimited-string-to-list "ab|" #\|) ("ab" ""))
 (deftest str.25 (delimited-string-to-list "ab|" #\| t) ("ab"))
 
+(deftest sdstl.1 (string-delimited-string-to-list "ab|cd|ef" "|a")
+  ("ab|cd|ef"))
+(deftest sdstl.2 (string-delimited-string-to-list "ab|cd|ef" "|")
+  ("ab" "cd" "ef"))
+(deftest sdstl.3 (string-delimited-string-to-list "ab|cd|ef" "cd")
+  ("ab|" "|ef"))
+(deftest sdstl.4 (string-delimited-string-to-list "ab|cd|ef" "ab")
+  ("" "|cd|ef"))
+
 (deftest apsl.1 (append-sublists '((a b) (c d))) (a b c d))
 (deftest apsl.2 (append-sublists nil) nil)
 (deftest apsl.3 (append-sublists '((a b))) (a b))
 (deftest css.4 (concat-separated-strings "|" '("ab" "cd") nil) "ab|cd")
 (deftest css.5 (concat-separated-strings "|" '("ab" "cd") nil '("ef")) "ab|cd|ef")
 
-(deftest f.1 (filter #'(lambda (x) (when (oddp x) (* x x)))
+(deftest f.1 (map-and-remove-nils #'(lambda (x) (when (oddp x) (* x x)))
                     '(0 1 2 3 4 5 6 7 8 9)) (1 9 25 49 81))
+(deftest f.2 (filter #'(lambda (x) (when (oddp x) (* x x)))
+                    '(0 1 2 3 4 5 6 7 8 9)) (1 3 5 7 9))
 (deftest an.1 (appendnew '(a b c d) '(c c e f)) (a b c d e f))
 
 
   (xml-tag-contents "tag1" "<tag>Test</tag>")
   nil nil nil)
 
-(deftest pxml.1o
-  (kmrcl::xml-tag-contents-old "tag1" "<tag>Test</tag>")
-  nil nil)
-
 (deftest pxml.2
   (xml-tag-contents "tag" "<tag>Test</tag>")
   "Test" 15 nil)
 (deftest stlsd.9 (string-to-list-skip-delimiter "ab,,c,," #\,) ("ab" "c"))
 (deftest stlsd.10 (string-to-list-skip-delimiter " ab") ("ab"))
 
+(deftest csc.1 (count-string-char "" #\a) 0)
+(deftest csc.2 (count-string-char "abc" #\d) 0)
+(deftest csc.3 (count-string-char "abc" #\b) 1)
+(deftest csc.4 (count-string-char "abcb" #\b) 2)
+
+(deftest duqs.1 (decode-uri-query-string "") "")
+(deftest duqs.2 (decode-uri-query-string "abc") "abc")
+(deftest duqs.3 (decode-uri-query-string "abc+") "abc ")
+(deftest duqs.4 (decode-uri-query-string "abc+d") "abc d")
+(deftest duqs.5 (decode-uri-query-string "abc%20d") "abc d")
+
+(deftest sse.1 (string-strip-ending "" nil) "")
+(deftest sse.2 (string-strip-ending "abc" nil) "abc")
+(deftest sse.3 (string-strip-ending "abc" "ab") "abc")
+(deftest sse.4 (string-strip-ending "abc" '("ab")) "abc")
+(deftest sse.5 (string-strip-ending "abcd" '("a" "cd")) "ab")
+
+  
 ;;; MOP Testing
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
 
 #+kmrtest-mop
 (progn
+  (setf (find-class 'monitored-credit-rating) nil)
+  (setf (find-class 'credit-rating) nil)
+  
   (defclass credit-rating ()
     ((level :attributes (date-set time-set))
      (id :attributes (person-setting)))
-    (:metaclass attributes-class))
-  (defparameter cr nil)
+    (:metaclass attributes-class)
+    #+lispworks (:optimize-slot-access nil)
+    )
   
   (defclass monitored-credit-rating (credit-rating)
     ((level :attributes (last-checked interval date-set))
      (cc :initarg :cc)
      (id :attributes (verified)))
     (:metaclass attributes-class))
-  (defparameter mcr (make-instance 'monitored-credit-rating))
 
   (deftest attrib.mop.1
-      (progn
-       (setq cr (make-instance 'credit-rating))
+      (let ((cr (make-instance 'credit-rating)))
        (slot-attribute cr 'level 'date-set))
       nil)
 
   (deftest attrib.mop.2
-      (progn
-       (setq cr (make-instance 'credit-rating))
+      (let ((cr (make-instance 'credit-rating)))
        (setf (slot-attribute cr 'level 'date-set) "12/15/1990")
        (slot-attribute cr 'level 'date-set))
     "12/15/1990")
 
   (deftest attrib.mop.3
-      (progn
-       (setq mcr (make-instance 'monitored-credit-rating))
+      (let ((mcr (make-instance 'monitored-credit-rating)))
        (setf (slot-attribute mcr 'level 'date-set) "01/05/2002")
        (slot-attribute mcr 'level 'date-set))
     "01/05/2002")