Update of /project/cl-cli-parser/cvsroot/cl-cli-parser
In directory common-lisp.net:/tmp/cvs-serv7094
Modified Files:
cli-parser-test.lisp
Log Message:
refactored to use unit-test.lisp, instead of the stupid thing I wrote when
I was learning lisp.
Date: Sat Mar 19 23:18:43 2005
Author: dbueno
Index: cl-cli-parser/cli-parser-test.lisp
diff -u cl-cli-parser/cli-parser-test.lisp:1.1 cl-cli-parser/cli-parser-test.lisp:1.2
--- cl-cli-parser/cli-parser-test.lisp:1.1 Sat Mar 19 22:41:45 2005
+++ cl-cli-parser/cli-parser-test.lisp Sat Mar 19 23:18:43 2005
@@ -1,4 +1,4 @@
-;;; $Id: cli-parser-test.lisp,v 1.1 2005/03/19 21:41:45 dbueno Exp $
+;;; $Id: cli-parser-test.lisp,v 1.2 2005/03/19 22:18:43 dbueno Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; AGNS - Automatic (G-something) N-gram Spelling Corrector
;;; Denis Bueno
@@ -8,7 +8,6 @@
(in-package :cli-parser)
(use-package :lunit)
-(set-current-unit :cli)
(deftest test-opt-p ()
@@ -33,40 +32,41 @@
(opt2 "--jthingie=123")
(opt3 "--thing=1 2 3")
(opt4 "--k"))
- (check (full-opt-p opt1))
- (check (full-opt-p opt2))
- (check (full-opt-p opt3))
- (check (full-opt-p "--thing 1 2 3"))
- (check (full-opt-p "--thing 1,2,3"))
+ (check (full-opt-p opt1))
+ (check (full-opt-p opt2))
+ (check (full-opt-p opt3))
+ (check (full-opt-p "--thing 1 2 3"))
+ (check (full-opt-p "--thing 1,2,3"))
(check (full-opt-p opt4))
(check (full-opt-p "-cookycrisp"))
(check (full-opt-p "-k=3"))
(check (full-opt-p "-k 3"))))
(deftest test-end-opt-name ()
- (check 7 (end-opt-name "--crazy"))
- (check 2 (end-opt-name "-c"))
- (check 7 (end-opt-name "--happy=25"))
- (check 7 (end-opt-name "--happy 25")))
+ (check (= 7 (end-opt-name "--crazy"))
+ (= 2 (end-opt-name "-c"))
+ (= 7 (end-opt-name "--happy=25"))
+ (= 7 (end-opt-name "--happy 25"))))
(deftest test-opt-name ()
- (check "crazy" (opt-name "--crazy"))
- (check "o" (opt-name "-o"))
- (check "crazy" (opt-name "--crazy=1299"))
- (check "o" (opt-name "-o=678"))
- (check "crazy" (opt-name "--crazy 1299"))
- (check "o" (opt-name "-o 678")))
+ (check (string="crazy" (opt-name "--crazy"))
+ (string= "o" (opt-name "-o"))
+ (string= "crazy" (opt-name "--crazy=1299"))
+ (string= "o" (opt-name "-o=678"))
+ (string= "crazy" (opt-name "--crazy 1299"))
+ (string= "o" (opt-name "-o 678"))))
(deftest test-opt-values ()
- (check (opt-values "--some-option"))
- (check '("x" "y" "z") (opt-values "--some-option=x y z "))
- (check '("x" "y" "z") (opt-values "--opt=x,y,z"))
- (check '("x" "y" "z") (opt-values "--opt x,y,z"))
- (check '("x" "y" "z") (opt-values "--opt x y z"))
- (check '("1" "2") (opt-values "-x=1 2"))
- (check '("1") (opt-values "-x=1"))
- (check '("1") (opt-values "-x 1"))
- (check '("1") (opt-values "--stupid 1")))
+ (check
+ (null (opt-values "--some-option"))
+ (equalp '("x" "y" "z") (opt-values "--some-option=x y z "))
+ (equalp '("x" "y" "z") (opt-values "--opt=x,y,z"))
+ (equalp '("x" "y" "z") (opt-values "--opt x,y,z"))
+ (equalp '("x" "y" "z") (opt-values "--opt x y z"))
+ (equalp '("1" "2") (opt-values "-x=1 2"))
+ (equalp '("1") (opt-values "-x=1"))
+ (equalp '("1") (opt-values "-x 1"))
+ (equalp '("1") (opt-values "--stupid 1"))))
(defparameter *test-cli-opts*
(list
@@ -79,26 +79,28 @@
:example "-a, --artaxerxes")))
(deftest test-abbr->full-opt-name ()
- (check= "artaxerxes"
- (abbr->full-opt-name "a" *test-cli-opts*))
- (check= "ornithology"
- (abbr->full-opt-name "o" *test-cli-opts*))
- (check= "ornithology"
- (abbr->full-opt-name "ornithology" *test-cli-opts*))
- (check (abbr->full-opt-name "k" *test-cli-opts*)))
+ (check
+ (string= "artaxerxes"
+ (abbr->full-opt-name "a" *test-cli-opts*))
+ (string= "ornithology"
+ (abbr->full-opt-name "o" *test-cli-opts*))
+ (string= "ornithology"
+ (abbr->full-opt-name "ornithology" *test-cli-opts*))
+ (string= "k" (abbr->full-opt-name "k" *test-cli-opts*))))
(deftest test-coalesce-options ()
- (check '("--files=1 2 3")
- (coalesce-options '("--files=1" "2" "3")))
- (check '("--files 1 2 3")
- (coalesce-options '("--files" "1" "2" "3")))
- (check '("--files 1, 2, 3")
- (coalesce-options '("--files" "1," "2," "3")))
- (check '("--genre=fatty.xml"
- "--files=file1 file2 file3"
- "--some-other-things=1 2 3")
- (coalesce-options '("--genre=fatty.xml" "--files=file1" "file2"
- "file3" "--some-other-things=1" "2" "3"))))
+ (check
+ (equalp'("--files=1 2 3")
+ (coalesce-options '("--files=1" "2" "3")))
+ (equalp '("--files 1 2 3")
+ (coalesce-options '("--files" "1" "2" "3")))
+ (equalp '("--files 1, 2, 3")
+ (coalesce-options '("--files" "1," "2," "3")))
+ (equalp '("--genre=fatty.xml"
+ "--files=file1 file2 file3"
+ "--some-other-things=1 2 3")
+ (coalesce-options '("--genre=fatty.xml" "--files=file1" "file2"
+ "file3" "--some-other-things=1" "2" "3")))))
(deftest test-cli-parse-hash ()
(let ((test1 (list "--ornithology=x-value" "-a y-value"))