delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2004/02/24/01:38:12

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Date: 24 Feb 2004 08:35:01 +0200
Message-Id: <u4qthj88a.fsf@elta.co.il>
From: Eli Zaretskii <eliz AT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
In-reply-to: <200402232034.i1NKYqrt024366@envy.delorie.com> (message from DJ
Delorie on Mon, 23 Feb 2004 15:34:52 -0500)
Subject: Re: strtoul bug (was Re: Fibonacci number)
References: <d7c3a0b2 DOT 0402220759 DOT 34d6435d AT posting DOT google DOT com> <4038E8CA DOT 6491815E AT virginia DOT edu> <4039DD96 DOT 3F36F3B7 AT yahoo DOT com> <200402231458 DOT i1NEwKwm020904 AT envy DOT delorie DOT com> <403A301C DOT E8F5FE65 AT yahoo DOT com> <200402231751 DOT i1NHp5lv022894 AT envy DOT delorie DOT com> <403A5F55 DOT 7E608910 AT yahoo DOT com> <200402232034 DOT i1NKYqrt024366 AT envy DOT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019