Re: [PATCH 1/3] Correct test-parse-options to handle negative ints

2015-06-19 Thread Junio C Hamano
Charles Bailey  writes:

> From: Charles Bailey 
>
> 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 
> ---

Makes sense.  Will queue.

>  t/t0040-parse-options.sh | 2 ++
>  test-parse-options.c | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
> index b044785..ecb7417 100755
> --- a/t/t0040-parse-options.sh
> +++ b/t/t0040-parse-options.sh
> @@ -151,6 +151,8 @@ test_expect_success 'short options' '
>   test_must_be_empty output.err
>  '
>  
> +test_expect_success 'OPT_INT() negative' 'check integer: -2345 -i -2345'
> +
>  cat > expect << EOF
>  boolean: 2
>  integer: 1729
> diff --git a/test-parse-options.c b/test-parse-options.c
> index 5dabce6..7c492cf 100644
> --- a/test-parse-options.c
> +++ b/test-parse-options.c
> @@ -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);
--
To unsubscribe from this list: send the line "unsubscribe git" in


[PATCH 1/3] Correct test-parse-options to handle negative ints

2015-06-19 Thread Charles Bailey
From: Charles Bailey 

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 
---
 t/t0040-parse-options.sh | 2 ++
 test-parse-options.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index b044785..ecb7417 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -151,6 +151,8 @@ test_expect_success 'short options' '
test_must_be_empty output.err
 '
 
+test_expect_success 'OPT_INT() negative' 'check integer: -2345 -i -2345'
+
 cat > expect << EOF
 boolean: 2
 integer: 1729
diff --git a/test-parse-options.c b/test-parse-options.c
index 5dabce6..7c492cf 100644
--- a/test-parse-options.c
+++ b/test-parse-options.c
@@ -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);
-- 
2.4.0.53.g8440f74

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html