Mail Archives: djgpp-workers/2004/02/24/01:38:12
> Date: Mon, 23 Feb 2004 15:34:52 -0500
> From: DJ Delorie <dj AT delorie DOT com>
>
> 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 }
> }
Indeed. See the test vectors in the `cygnus' directory of
djtstNNN.zip and the associated test functions, they use precisely
this approach for testing many functions, including strtod, strtol,
etc. So it sounds like just adding strtoul to that would be the best
approach.
- Raw text -