added tests for CmdLine arg

This commit is contained in:
mes5k 2004-09-12 02:35:14 +00:00
parent 77592b3a83
commit 6cc1ce8463
17 changed files with 218 additions and 2 deletions

View File

@ -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

7
tests/test47.out Normal file
View File

@ -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

11
tests/test47.sh Executable file
View File

@ -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

7
tests/test48.out Normal file
View File

@ -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

11
tests/test48.sh Executable file
View File

@ -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

11
tests/test49.out Normal file
View File

@ -0,0 +1,11 @@
PARSE ERROR: Argument: -s (--stringTest)
Couldn't find delimiter for this argument!
Brief USAGE:
../examples/test8 [-f=<float>] ... [-i=<int>] ... -s=<string> [-B]
[--] [-v] [-h] <string> <string> <fileNameString>
...
For complete USAGE and HELP type:
../examples/test8 --help

11
tests/test49.sh Executable file
View File

@ -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

11
tests/test50.out Normal file
View File

@ -0,0 +1,11 @@
PARSE ERROR: Argument: -s (--stringTest)
Couldn't find delimiter for this argument!
Brief USAGE:
../examples/test8 [-f=<float>] ... [-i=<int>] ... -s=<string> [-B]
[--] [-v] [-h] <string> <string> <fileNameString>
...
For complete USAGE and HELP type:
../examples/test8 --help

11
tests/test50.sh Executable file
View File

@ -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

11
tests/test51.out Normal file
View File

@ -0,0 +1,11 @@
PARSE ERROR:
One or more required arguments missing!
Brief USAGE:
../examples/test8 [-f=<float>] ... [-i=<int>] ... -s=<string> [-B]
[--] [-v] [-h] <string> <string> <fileNameString>
...
For complete USAGE and HELP type:
../examples/test8 --help

11
tests/test51.sh Executable file
View File

@ -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

11
tests/test52.out Normal file
View File

@ -0,0 +1,11 @@
PARSE ERROR: Argument: -i (--intTest)
Couldn't read argument value from string '9a'
Brief USAGE:
../examples/test8 [-f=<float>] ... [-i=<int>] ... -s=<string> [-B]
[--] [-v] [-h] <string> <string> <fileNameString>
...
For complete USAGE and HELP type:
../examples/test8 --help

11
tests/test52.sh Executable file
View File

@ -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

11
tests/test53.out Normal file
View File

@ -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=<float>] ... [-i=<int>] ... -s=<string> [-B]
[--] [-v] [-h] <string> <string> <fileNameString>
...
For complete USAGE and HELP type:
../examples/test8 --help

11
tests/test53.sh Executable file
View File

@ -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

43
tests/test54.out Normal file
View File

@ -0,0 +1,43 @@
USAGE:
../examples/test8 [-f=<float>] ... [-i=<int>] ... -s=<string> [-B]
[--] [-v] [-h] <string> <string> <fileNameString>
...
Where:
-f <float>, --floatTest <float> (accepted multiple times)
(value required) multi float test
-i <int>, --intTest <int> (accepted multiple times)
(value required) multi int test
-s <string>, --stringTest <string>
(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.
<string>
(required) (value required) unlabeled test one
<string>
(required) (value required) unlabeled test two
<fileNameString> (accepted multiple times)
(value required) file names
this is a message

11
tests/test54.sh Executable file
View File

@ -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