From 6cc1ce8463591dbf40edd10f6d2873673af6d493 Mon Sep 17 00:00:00 2001 From: mes5k Date: Sun, 12 Sep 2004 02:35:14 +0000 Subject: [PATCH] added tests for CmdLine arg --- tests/Makefile.am | 20 ++++++++++++++++++-- tests/test47.out | 7 +++++++ tests/test47.sh | 11 +++++++++++ tests/test48.out | 7 +++++++ tests/test48.sh | 11 +++++++++++ tests/test49.out | 11 +++++++++++ tests/test49.sh | 11 +++++++++++ tests/test50.out | 11 +++++++++++ tests/test50.sh | 11 +++++++++++ tests/test51.out | 11 +++++++++++ tests/test51.sh | 11 +++++++++++ tests/test52.out | 11 +++++++++++ tests/test52.sh | 11 +++++++++++ tests/test53.out | 11 +++++++++++ tests/test53.sh | 11 +++++++++++ tests/test54.out | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/test54.sh | 11 +++++++++++ 17 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 tests/test47.out create mode 100755 tests/test47.sh create mode 100644 tests/test48.out create mode 100755 tests/test48.sh create mode 100644 tests/test49.out create mode 100755 tests/test49.sh create mode 100644 tests/test50.out create mode 100755 tests/test50.sh create mode 100644 tests/test51.out create mode 100755 tests/test51.sh create mode 100644 tests/test52.out create mode 100755 tests/test52.sh create mode 100644 tests/test53.out create mode 100755 tests/test53.sh create mode 100644 tests/test54.out create mode 100755 tests/test54.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index acd2912..61e2820 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,7 +45,15 @@ TESTS = test1.sh \ test43.sh \ test44.sh \ test45.sh \ - test46.sh + test46.sh \ + test47.sh \ + test48.sh \ + test49.sh \ + test50.sh \ + test51.sh \ + test52.sh \ + test53.sh \ + test54.sh EXTRA_DIST = $(TESTS) \ test1.out \ @@ -93,5 +101,13 @@ EXTRA_DIST = $(TESTS) \ test43.out \ test44.out \ test45.out \ - test46.out + test46.out \ + test47.out \ + test48.out \ + test49.out \ + test50.out \ + test51.out \ + test52.out \ + test53.out \ + test54.out diff --git a/tests/test47.out b/tests/test47.out new file mode 100644 index 0000000..076f079 --- /dev/null +++ b/tests/test47.out @@ -0,0 +1,7 @@ +[-i] 0 9 +[-i] 1 8 +[ ] 0 bart +for string we got : bill +for ulabeled one we got : homer +for ulabeled two we got : marge +for bool B we got : 1 diff --git a/tests/test47.sh b/tests/test47.sh new file mode 100755 index 0000000..d209e2f --- /dev/null +++ b/tests/test47.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# success +../examples/test8 -s=bill -i=9 -i=8 -B homer marge bart > tmp.out 2>&1 + +if cmp -s tmp.out test47.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test48.out b/tests/test48.out new file mode 100644 index 0000000..404d810 --- /dev/null +++ b/tests/test48.out @@ -0,0 +1,7 @@ +[ ] 0 bart +[ ] 1 one +[ ] 2 two +for string we got : aaa +for ulabeled one we got : homer +for ulabeled two we got : marge +for bool B we got : 0 diff --git a/tests/test48.sh b/tests/test48.sh new file mode 100755 index 0000000..d0a4f26 --- /dev/null +++ b/tests/test48.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# success +../examples/test8 -s=aaa homer marge bart -- one two > tmp.out 2>&1 + +if cmp -s tmp.out test48.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test49.out b/tests/test49.out new file mode 100644 index 0000000..ca5e829 --- /dev/null +++ b/tests/test49.out @@ -0,0 +1,11 @@ +PARSE ERROR: Argument: -s (--stringTest) + Couldn't find delimiter for this argument! + +Brief USAGE: + ../examples/test8 [-f=] ... [-i=] ... -s= [-B] + [--] [-v] [-h] + ... + +For complete USAGE and HELP type: + ../examples/test8 --help + diff --git a/tests/test49.sh b/tests/test49.sh new file mode 100755 index 0000000..af01461 --- /dev/null +++ b/tests/test49.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# failure +../examples/test8 -s bbb homer marge bart -- -hv two > tmp.out 2>&1 + +if cmp -s tmp.out test49.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test50.out b/tests/test50.out new file mode 100644 index 0000000..ca5e829 --- /dev/null +++ b/tests/test50.out @@ -0,0 +1,11 @@ +PARSE ERROR: Argument: -s (--stringTest) + Couldn't find delimiter for this argument! + +Brief USAGE: + ../examples/test8 [-f=] ... [-i=] ... -s= [-B] + [--] [-v] [-h] + ... + +For complete USAGE and HELP type: + ../examples/test8 --help + diff --git a/tests/test50.sh b/tests/test50.sh new file mode 100755 index 0000000..adab0c2 --- /dev/null +++ b/tests/test50.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# failure +../examples/test8 -s one homer -B -Bh > tmp.out 2>&1 + +if cmp -s tmp.out test50.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test51.out b/tests/test51.out new file mode 100644 index 0000000..f9acc1d --- /dev/null +++ b/tests/test51.out @@ -0,0 +1,11 @@ +PARSE ERROR: + One or more required arguments missing! + +Brief USAGE: + ../examples/test8 [-f=] ... [-i=] ... -s= [-B] + [--] [-v] [-h] + ... + +For complete USAGE and HELP type: + ../examples/test8 --help + diff --git a/tests/test51.sh b/tests/test51.sh new file mode 100755 index 0000000..e3bb501 --- /dev/null +++ b/tests/test51.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# failure +../examples/test8 -s=one homer -B > tmp.out 2>&1 + +if cmp -s tmp.out test51.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test52.out b/tests/test52.out new file mode 100644 index 0000000..c28e368 --- /dev/null +++ b/tests/test52.out @@ -0,0 +1,11 @@ +PARSE ERROR: Argument: -i (--intTest) + Couldn't read argument value from string '9a' + +Brief USAGE: + ../examples/test8 [-f=] ... [-i=] ... -s= [-B] + [--] [-v] [-h] + ... + +For complete USAGE and HELP type: + ../examples/test8 --help + diff --git a/tests/test52.sh b/tests/test52.sh new file mode 100755 index 0000000..cb0f3b0 --- /dev/null +++ b/tests/test52.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# failure +../examples/test8 -i=9a -i=1 -s=asdf asdf asdf > tmp.out 2>&1 + +if cmp -s tmp.out test52.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test53.out b/tests/test53.out new file mode 100644 index 0000000..fd15cd5 --- /dev/null +++ b/tests/test53.out @@ -0,0 +1,11 @@ +PARSE ERROR: Argument: -f (--floatTest) + More than one valid value parsed from string '1.0.0' + +Brief USAGE: + ../examples/test8 [-f=] ... [-i=] ... -s= [-B] + [--] [-v] [-h] + ... + +For complete USAGE and HELP type: + ../examples/test8 --help + diff --git a/tests/test53.sh b/tests/test53.sh new file mode 100755 index 0000000..4922a07 --- /dev/null +++ b/tests/test53.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# failure +../examples/test8 -f=9 -f=1.0.0 -s=asdf asdf asdf > tmp.out 2>&1 + +if cmp -s tmp.out test53.out; then + exit 0 +else + exit 1 +fi + diff --git a/tests/test54.out b/tests/test54.out new file mode 100644 index 0000000..1c1bf5e --- /dev/null +++ b/tests/test54.out @@ -0,0 +1,43 @@ + +USAGE: + + ../examples/test8 [-f=] ... [-i=] ... -s= [-B] + [--] [-v] [-h] + ... + + +Where: + + -f , --floatTest (accepted multiple times) + (value required) multi float test + + -i , --intTest (accepted multiple times) + (value required) multi int test + + -s , --stringTest + (required) (value required) string test + + -B, --existTestB + exist Test B + + --, --ignore_rest + Ignores the rest of the labeled arguments following this flag. + + -v, --version + Displays version information and exits. + + -h, --help + Displays usage information and exits. + + + (required) (value required) unlabeled test one + + + (required) (value required) unlabeled test two + + (accepted multiple times) + (value required) file names + + + this is a message + diff --git a/tests/test54.sh b/tests/test54.sh new file mode 100755 index 0000000..7899576 --- /dev/null +++ b/tests/test54.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# success +../examples/test8 --help > tmp.out 2>&1 + +if cmp -s tmp.out test54.out; then + exit 0 +else + exit 1 +fi +