diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-05-23 01:38:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-05-23 01:38:32 -0700 |
commit | 104d3794481c83f8db00ccf85134fc55c76852f9 (patch) | |
tree | ddd0c863652be1ecade06d66bca1e8eb5fb37409 /t | |
parent | 9d764f9538f63d654a1147e11920c2bc36b75194 (diff) | |
parent | ff3c7f9a264da41a2cd7b7a28a27f8ad935b81a9 (diff) | |
download | git-104d3794481c83f8db00ccf85134fc55c76852f9.tar.gz |
Merge branch 'rs/grep-parseopt'
* rs/grep-parseopt:
grep: make callback functions static
grep: use parseopt
grep: remove global variable builtin_grep
parseopt: add PARSE_OPT_NODASH
parseopt: add OPT_NUMBER_CALLBACK
parseopt: add OPT_NEGBIT
Diffstat (limited to 't')
-rwxr-xr-x | t/t0040-parse-options.sh | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index e38241c80a..a40c1236c0 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -12,6 +12,7 @@ usage: test-parse-options <options> -b, --boolean get a boolean -4, --or4 bitwise-or boolean with ...0100 + --neg-or4 same as --no-or4 -i, --integer <n> get a integer -j <n> get a integer, too @@ -29,6 +30,8 @@ String options Magic arguments --quux means --quux + -NUM set integer to NUM + + same as -b Standard options --abbrev[=<n>] use <n> digits to display SHA-1s @@ -245,7 +248,56 @@ test_expect_success 'OPT_BIT() and OPT_SET_INT() work' ' test_cmp expect output ' -# --or4 -# --no-or4 +test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' ' + test-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err && + test ! -s output.err && + test_cmp expect output +' + +cat > expect <<EOF +boolean: 6 +integer: 0 +timestamp: 0 +string: (not set) +abbrev: 7 +verbose: 0 +quiet: no +dry run: no +EOF + +test_expect_success 'OPT_BIT() works' ' + test-parse-options -bb --or4 > output 2> output.err && + test ! -s output.err && + test_cmp expect output +' + +test_expect_success 'OPT_NEGBIT() works' ' + test-parse-options -bb --no-neg-or4 > output 2> output.err && + test ! -s output.err && + test_cmp expect output +' + +test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' ' + test-parse-options + + + + + + > output 2> output.err && + test ! -s output.err && + test_cmp expect output +' + +cat > expect <<EOF +boolean: 0 +integer: 12345 +timestamp: 0 +string: (not set) +abbrev: 7 +verbose: 0 +quiet: no +dry run: no +EOF + +test_expect_success 'OPT_NUMBER_CALLBACK() works' ' + test-parse-options -12345 > output 2> output.err && + test ! -s output.err && + test_cmp expect output +' test_done |