Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test-parse-options: update to handle negative ints
Fix the printf specification to treat 'integer' as the signed type
that it is and add a test that checks that we parse negative option
arguments.

Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Charles Bailey authored and Junio C Hamano committed Jun 22, 2015
1 parent 5c040f5 commit 81a48cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions t/t0040-parse-options.sh
Expand Up @@ -132,6 +132,8 @@ test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear

test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'

test_expect_success 'OPT_INT() negative' 'check integer: -2345 -i -2345'

cat > expect << EOF
boolean: 2
integer: 1729
Expand Down
2 changes: 1 addition & 1 deletion test-parse-options.c
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char **argv)
argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);

printf("boolean: %d\n", boolean);
printf("integer: %u\n", integer);
printf("integer: %d\n", integer);
printf("timestamp: %lu\n", timestamp);
printf("string: %s\n", string ? string : "(not set)");
printf("abbrev: %d\n", abbrev);
Expand Down

0 comments on commit 81a48cc

Please sign in to comment.