[bigint] [MMWS/bigint/] Patch: Adding (some) 64-bit tests and fixing 64-bit bugs
Brad Spencer <spencer at starscale.com>
Wed Sep 24 16:42:54 PDT 2008
Hi, again :) I once again had occasion to look at your C++ Big Integer
Library, and I have another patch for you. I use primarily 64-bit
targets these days, so I took some time and expanded the test suite to
be 64-bit friendly.
I added a few tests that test the 2^64 boundaries as analogues to
those testing near the 2^32 boundaries. I also changed a few tests so
that the whole suite works for both a 32-bit and 64-bit unsigned long
type.
Because of the way test suite works, with all the expected values in
comments, I had to pull a few tricks to make all this work. Some of
it is a little ugly, but it's better than having no 64-bit tests, I
figure.
The 64-bit tests I added are for both a 64-bit int and a 64-bit long,
but I don't have a usable target with 64-bit int, so they're guesses.
During all this, I found two untyped (and thus int) literal integers
in the code that caused breakage when sizeof(int) == 4 and
sizeof(long) == 8, which is the case for me. I fixed them, and
briefly grepped for others, but didn't find any.
Anyway, the net result is that after applying this patch to
bigint-2008.07.20 the test suite passes without modification on both
x86_64-unknown-linux-gnu and i686-pc-linux-gnu.
I hope this is of use. Ensuring coverage on tests like this is
difficult, and I hope I haven't accidentally removed a previous test
as part of this work. I tried to follow the existing style and
formatting where possible, but my editor inserts spaces, not tabs, so
be warned :)
I, Brad Spencer, the sole author of the attached patch for the Big
Integer Library, waive my copyright to it, placing it in the public
domain. The patch comes with absolutely no warranty.
BTW, any chance of putting this library in some kind of namespace
out-of-the-box? Would you be opposed to a patch including a
use-customizable make environment variable that did so?
--
----------------------------------------------------------
Brad Spencer - spencer at starscale.com - www.starscale.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bigint-2008.07.20.64-bit.diff
Type: text/x-diff
Size: 13341 bytes
Desc: not available
URL: <http://mattmccutchen.net/mailman/archives/bigint/attachments/20080924/889d8dd9/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mattmccutchen.net/mailman/archives/bigint/attachments/20080924/889d8dd9/attachment.pgp>
More information about the bigint
mailing list