Mail Archives: djgpp-workers/2004/02/24/01:50:08
DJ Delorie wrote:
>
> I'm thinking something table-driven would be better; no user input
> should be needed for a test case. How about a table like this?
>
> struct {
> char *input_string;
> int base; /*
> int expected_endp; /* index into string */
> unsigned char expected_value[8];
> int expected_errno;
> } tests[] = {
> { "0", 0, 1, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0 },
> { "10x", 8, 2, { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0 },
> /* etc */
> { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }
> }
>
> We could have one table for each function (strtol, strtoul, strtoll,
> strtoull) and pass the table, function, and size of result (4 or 8) to
> a common "test this" function.
>
> The function should print nothing and exit(0) if they all pass, else
> print a diagnostic and exit(1) if any fail.
First I think we need a consensus as to what is in error. I have
posted something very similar to c.l.c and c.std.c to see what
appears. I still consider the acceptance of signs in the unsigned
varieties to be an error, but it may have been justified by the
number of such implementations in existance. TC 2.01 does NOT
accept them! which seems sane, if non-conforming.
--
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
- Raw text -