From 858f7b088dcc3ba8c56927c8b201f704b3babf2c Mon Sep 17 00:00:00 2001
From: Ken Harris <kengruven@gmail.com>
Date: Sun, 2 Jun 2013 10:13:01 -0700
Subject: [PATCH] Character case predicates.

---
 src/char.lisp         |    9 +++++++++
 tests/characters.lisp |   11 ++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/char.lisp b/src/char.lisp
index 6fe28b6..2a36d91 100644
--- a/src/char.lisp
+++ b/src/char.lisp
@@ -282,6 +282,15 @@ character exists."
          (or (< 31 n 127)
              (= n 10)))))
 
+(defun upper-case-p (character)
+  (char/= character (char-downcase character)))
+
+(defun lower-case-p (character)
+  (char/= character (char-upcase character)))
+
+(defun both-case-p (character)
+  (or (upper-case-p character) (lower-case-p character)))
+
 (defun char-int (character)
   ;; no implementation-defined character attributes
   (char-code character))
diff --git a/tests/characters.lisp b/tests/characters.lisp
index dc0cf68..aa8388e 100644
--- a/tests/characters.lisp
+++ b/tests/characters.lisp
@@ -37,8 +37,6 @@
 ;; (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
 
-;; TODO: char/=, char<, etc.
-
 ;; CHARACTER
 (test (equal #\a (character #\a)))
 (test (equal #\a (character "a")))
@@ -114,7 +112,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)))
-- 
1.7.10.4