X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcharacters.lisp;h=74679f6f00487f4595cb3330eaeb76a5de598b75;hb=ba8e96ec1d0ab80c668fda471f2acb6ef55c5e61;hp=975f35859239864a06aced51ec37b35ca8389010;hpb=a38d48850754e354abe9c99848a087bfd7062214;p=jscl.git diff --git a/tests/characters.lisp b/tests/characters.lisp index 975f358..74679f6 100644 --- a/tests/characters.lisp +++ b/tests/characters.lisp @@ -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))) @@ -54,7 +88,10 @@ (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)) @@ -78,7 +115,14 @@ (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))) @@ -88,12 +132,22 @@ ;; CHAR-INT (test (= (char-int #\A) (char-int #\A))) ;; can be pretty much anything, as long as it's consistent -;; CHAR-TO-STRING (not actually part of the characters dictionary) -(test (= 1 (string-length (char-to-string (code-char 127744))))) +(test (= 1 (length (string (code-char 127744))))) ;; CHAR-CODE-LIMIT (test (< 95 char-code-limit 10000000)) -;; TODO: CHAR-NAME - -;; TODO: NAME-CHAR +;; CHAR-NAME +(test (string= "Space" (char-name #\ ))) +;; (test (string= "Space" (char-name #\Space))) +(test (string= "Page" (char-name (code-char 12)))) ;; #\Page +(test (string= "LATIN_SMALL_LETTER_A" (char-name #\a))) +(test (string= "LATIN_CAPITAL_LETTER_A" (char-name #\A))) + +;; NAME-CHAR +(test (char= #\ (name-char 'space))) ;; should be: #\Space +(test (char= #\ (name-char "space"))) ;; #\Space +(test (char= #\ (name-char "Space"))) ;; #\Space +(test + (let ((x (char-name #\a))) + (or (not x) (eql (name-char x) #\a))))