fuse_opt: testing

This commit is contained in:
Bill Zissimopoulos 2016-05-29 23:31:53 -07:00
parent 74a943d8d7
commit ead273ae18
2 changed files with 15 additions and 1 deletions

View File

@ -68,7 +68,7 @@ static long long strtoint(const char *p, const char *endp, int base, int is_sign
{ {
c |= 0x20; c |= 0x20;
if ('a' <= c && c <= maxalp) if ('a' <= c && c <= maxalp)
v = base * v + (c - 'a'); v = base * v + (c - 'a') + 10;
else else
break; break;
} }

View File

@ -14,6 +14,7 @@ struct data
short x; short x;
long y; long y;
long long z; long long z;
int dec, neg, hex, oct;
int arg_discard, arg_keep; int arg_discard, arg_keep;
int opt_discard, opt_keep; int opt_discard, opt_keep;
int nonopt_discard, nonopt_keep; int nonopt_discard, nonopt_keep;
@ -191,6 +192,11 @@ void fuse_opt_parse_test(void)
{ "-y=%li", offsetof(struct data, y), 'y' }, { "-y=%li", offsetof(struct data, y), 'y' },
{ "-z=%lli", offsetof(struct data, z), 'z' }, { "-z=%lli", offsetof(struct data, z), 'z' },
{ "--dec=%d", offsetof(struct data, dec), 'dec' },
{ "--neg=%d", offsetof(struct data, neg), 'neg' },
{ "--hex=%x", offsetof(struct data, hex), 'hex' },
{ "--oct=%o", offsetof(struct data, oct), 'oct' },
FUSE_OPT_KEY("--discard", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("--discard", FUSE_OPT_KEY_DISCARD),
FUSE_OPT_KEY("--keep", FUSE_OPT_KEY_KEEP), FUSE_OPT_KEY("--keep", FUSE_OPT_KEY_KEEP),
@ -221,6 +227,10 @@ void fuse_opt_parse_test(void)
"-x=65537", "-x=65537",
"-y=0x100000001", "-y=0x100000001",
"-z=0x100000001", "-z=0x100000001",
"--dec=+1234567890",
"--neg=-1234567890",
"--hex=ABCDEF",
"--oct=12345670",
"--discard", "--discard",
"--keep", "--keep",
"--arg-discard", "--arg-discard",
@ -286,6 +296,10 @@ void fuse_opt_parse_test(void)
ASSERT(1 == data.x); ASSERT(1 == data.x);
ASSERT((long)0x100000001 == data.y); ASSERT((long)0x100000001 == data.y);
ASSERT((long long)0x100000001 == data.z); ASSERT((long long)0x100000001 == data.z);
ASSERT(+1234567890 == data.dec);
ASSERT(-1234567890 == data.neg);
ASSERT(0xABCDEF == data.hex);
ASSERT(012345670 == data.oct);
ASSERT(1 == data.arg_discard); ASSERT(1 == data.arg_discard);
ASSERT(1 == data.arg_keep); ASSERT(1 == data.arg_keep);
ASSERT(1 == data.opt_discard); ASSERT(1 == data.opt_discard);