[Mono-list] number formatting

Miguel de Icaza miguel@ximian.com
10 Oct 2001 14:54:19 -0400


> I just added the number formatting for the integer types if anyone wants to
> play with it. I have a test that does

Excellent!   Thanks a lot for the contribution Derek!

>    for (int n = -10000; n < 10000; n++)
>     foreach (string format in formats)
> 	if (
> say something;
> 
> For all ints, uints, shorts, ushorts, longs, ulongs, sbytes, and bytes. It
> seems to be passing all the tests. If there is anyone who is interested in
> making an NUnit test for all that I'll send my test to them. I haven't
> played w/ NUnit enough to know if there would be an easier way other than a
> million lines of Assert(n.ToString("C4"), "$42,321.0000")'s.

What about:

	for (int n = -10000; n < 10000; n++)
		Assert ( [microsoft's] n.ToString(format) == [mono's] n.ToString(format) )

Could you post your test, or check it into CVS?

With the compiler I have learned to appreciate more and more having a
regression test suite.  Right now Ravi and I have a rule of `Do not
check in changes to the compiler in CVS if the test suite fails' which
is really helpful, because it is easy to break something
inadvertently.

It is easier to find a bug when you have fresh in your mind the
changes that you have done and can better infer the source of the
problem on far reaching so this has been very helpful for us.

> It also seems to be using the NumberFormatInfo stuff properly, but that'd be
> even harder to write a test for. There's a lot you can do with the
> NumberFormatInfo patterns and symbols to get custom printings of currency
> and percents and stuff, but you have to set up a FormatProvider and lay out
> patterns. If anyone is interested in NUnit'ing that I can send some tests I
> did with it.

Wow, you have done a great job!  i love the IntegerFormatter, thanks a
lot man!

Miguel.