]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-parse-options: update to handle negative ints
authorCharles Bailey <cbailey32@bloomberg.net>
Sun, 21 Jun 2015 18:25:43 +0000 (19:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Jun 2015 22:04:23 +0000 (15:04 -0700)
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>
t/t0040-parse-options.sh
test-parse-options.c

index b0447851750e3f196ea2da90f84ce31fefce30ae..372d521c25efdaf426ca4e252b946fc405f51646 100755 (executable)
@@ -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
index 5dabce60f363430d3800bdadc77b3617abbcbfb6..7c492cf724fd1c7339ec7bc2789fec48ac4b8892 100644 (file)
@@ -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);