X-Git-Url: https://git.jsancho.org/?p=guile-click.git;a=blobdiff_plain;f=tests%2Ftest-args.scm;fp=tests%2Ftest-args.scm;h=d41abe228490b216adfe9cba2fcf571f2abab988;hp=0000000000000000000000000000000000000000;hb=986fe49efb25343011f28262cd2b7afbf81dd78e;hpb=84da61950d4a4038f76fdb9f66e0bbbb71f75385 diff --git a/tests/test-args.scm b/tests/test-args.scm new file mode 100644 index 0000000..d41abe2 --- /dev/null +++ b/tests/test-args.scm @@ -0,0 +1,45 @@ +;;; Click --- Command Line Interface Creation Kit for GNU Guile +;;; Copyright © 2021 Javier Sancho +;;; +;;; This file is part of Click. +;;; +;;; Click is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Click is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Click. If not, see . + + +(define-module (tests test-args) + #:use-module (srfi srfi-64) + #:use-module (click args)) + + +(test-begin "test-args") + +(define option-spec + '((count (single-char #\c) (default 1)) + (name (prompt "Your name")) + (help (flag #t)))) + +(test-error #t (parse-args '("program" "--count") option-spec)) + +(test-error #t (parse-args '("program" "-x") option-spec)) + +(test-equal (parse-args '("program" "-c" "2" "--name" "joe") option-spec) + '((()) (name . "joe") (count . "2"))) + +(test-equal (parse-args '("program" "-c" "2" "command" "-x") option-spec) + '((() "command" "-x") (count . "2"))) + +(test-equal (get-values option-spec '((()) (name . "joe") (count . "2"))) + '((count . 2) (name . "joe") (help . #f))) + +(test-end "test-args")