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>
Charles Bailey committed
Jun 21, 2015 at 19:25 UTC
81a48cc08033a453bcb884ec0838a8f064a6611e
2 files changed
+3
-1
t/t0040-parse-options.sh
+2
@@ -132,6 +132,8 @@ test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear
132
133
test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
134
135
+test_expect_success 'OPT_INT() negative' 'check integer: -2345 -i -2345'
136
+
137
cat > expect << EOF
138
boolean: 2
139
integer: 1729
test-parse-options.c
+1
-1
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
82
argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
83
84
printf("boolean: %d\n", boolean);
85
- printf("integer: %u\n", integer);
85
+ printf("integer: %d\n", integer);
86
printf("timestamp: %lu\n", timestamp);
87
printf("string: %s\n", string ? string : "(not set)");
88
printf("abbrev: %d\n", abbrev);