Merge pull request #112 from kengruven/master
[jscl.git] / tests / characters.lisp
index 1528006..a745051 100644 (file)
@@ -1,7 +1,41 @@
-;; CHAR=
+;; CHAR=, CHAR/=, etc.
 (test (char= (code-char 127744) (code-char 127744)))
-
-;; TODO: char/=, char<, etc.
+(test (char= #\d #\d))
+(test (not (char= #\A #\a)))
+(test (not (char= #\d #\x)))
+(test (not (char= #\d #\D)))
+(test (not (char/= #\d #\d)))
+(test (char/= #\d #\x))
+(test (char/= #\d #\D))
+(test (char= #\d #\d #\d #\d))
+(test (not (char/= #\d #\d #\d #\d)))
+(test (not (char= #\d #\d #\x #\d)))
+(test (not (char/= #\d #\d #\x #\d)))
+(test (not (char= #\d #\y #\x #\c)))
+(test (char/= #\d #\y #\x #\c))
+(test (not (char= #\d #\c #\d)))
+(test (not (char/= #\d #\c #\d)))
+(test (char< #\d #\x))
+(test (char<= #\d #\x))
+(test (not (char< #\d #\d)))
+(test (char<= #\d #\d))
+(test (char< #\a #\e #\y #\z))
+(test (char<= #\a #\e #\y #\z))
+(test (not (char< #\a #\e #\e #\y)))
+(test (char<= #\a #\e #\e #\y))
+(test (char> #\e #\d))
+(test (char>= #\e #\d))
+(test (char> #\d #\c #\b #\a))
+(test (char>= #\d #\c #\b #\a))
+(test (not (char> #\d #\d #\c #\a)))
+(test (char>= #\d #\d #\c #\a))
+(test (not (char> #\e #\d #\b #\c #\a)))
+(test (not (char>= #\e #\d #\b #\c #\a)))
+;; (char> #\z #\A) =>  implementation-dependent
+;; (char> #\Z #\a) =>  implementation-dependent
+(test (char-equal #\A #\a))
+;; (stable-sort (list #\b #\A #\B #\a #\c #\C) #'char-lessp) =>  (#\A #\a #\b #\B #\c #\C)
+;; (stable-sort (list #\b #\A #\B #\a #\c #\C) #'char<) => implementation-dependent
 
 ;; CHARACTER
 (test (equal #\a (character #\a)))
 (test (null (digit-char-p #\a)))
 (test (= 10 (digit-char-p #\A 11)))
 (test (= 10 (digit-char-p #\a 11)))
-;; TODO: does the mapcar/lambda thing work here?
+;; (mapcar #'(lambda (radix)
+;;              (map 'list #'(lambda (x) (digit-char-p x radix))
+;;                   "059AaFGZ"))
+;;          '(2 8 10 16 36))
 
 ;; GRAPHIC-CHAR-P
 (test (graphic-char-p #\G))
 (test (char= (code-char 223) (char-downcase (code-char 223))))  ;; already lower case
 (test (char= (code-char 127744) (char-downcase (code-char 127744))))  ;; no lower case
 
-;; TODO: UPPER-CASE-P, LOWER-CASE-P, BOTH-CASE-P
+;; UPPER-CASE-P, LOWER-CASE-P, BOTH-CASE-P
+(test (upper-case-p #\A))
+(test (not (upper-case-p #\a)))
+(test (both-case-p #\a))
+(test (not (both-case-p #\5)))
+(test (not (lower-case-p #\5)))
+(test (not (upper-case-p #\5)))
+(test (not (upper-case-p (code-char 127744))))
 
 ;; CODE-CHAR, CHAR-CODE
 (test (char= #\A (code-char 65)))