From 6e7d67bed9f4d76943e2f1724acff1e16b8bf7ac Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Fri, 11 May 2012 19:24:01 -0400 Subject: [PATCH] libupkg: Make decodeindex test accept an empty string. This test app should not reject empty input outright, because it should be properly rejected by the function under test. --- test/decodeindex.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/decodeindex.c b/test/decodeindex.c index bbe15f4..d3f099a 100644 --- a/test/decodeindex.c +++ b/test/decodeindex.c @@ -86,6 +86,12 @@ static void print_version(void) static void print_bytes(FILE *f, int indent, void *buf, size_t n) { fprintf(f, "%*s", indent, ""); + + if (n == 0) { + printf("(empty)\n"); + return; + } + for (size_t i = 0; i < n; i++) fprintf(f, "%*s%.2hhx", i != 0, "", ((unsigned char *)buf)[i]); putc('\n', f); @@ -103,9 +109,6 @@ static int print_index(const char *hex) fprintf(stderr, "%s: invalid hex sequence: %s\n", progname, hex); goto out; - } else if (n == 0) { - fprintf(stderr, "%s: empty argument\n", progname); - goto out; } else if (n > sizeof buf) { fprintf(stderr, "%s: hex sequence too long: %s\n", progname, hex); -- 2.43.0