Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1891
| Date | 2012-07-05 05:19 -0700 |
|---|---|
| From | Patricia Shanahan <pats@acm.org> |
| Newsgroups | comp.programming |
| Subject | Re: Question about writing program tests |
| References | <decb22b8-858f-48c8-a438-0e754535afad@re8g2000pbc.googlegroups.com> <87liiyzlir.fsf@adaheads.sparre-andersen.dk> |
| Message-ID | <aOqdnTA_W97zG2jSnZ2dnUVZ_uednZ2d@earthlink.com> (permalink) |
On 7/5/2012 12:59 AM, Jacob Sparre Andersen wrote: > mike3 wrote: > >> Consider the programming of a bignum package. How would you write >> _tests_ for this -- more specifically, how do you validate the results >> of a bignum addition/subtraction/ multiplication/division routines >> without referring to the bignum package in the first place? > > a) Manually calculated results (what you call "hardwired"). Remember to > make test cases at and around the boundaries, where you are likely to > make mistakes. Note that "manually calculated" can include using a separate wide arithmetic program, such as bc, to generate expected answers. > > b) Verifying against a separate, independently developed library. > Preferably one which uses a completely different approach. > > c) Use a static analysis tool (this is technically not "testing") to > verify that the routines do what you want them to. > If b or c is practical, one of those would be sufficient taken alone. If I were going to have to depend on (a), I would supplement it with a couple of types of bulk testing: Do some test cases that are in-range for the widest available built-in data type, using the built-in arithmetic to generate the expected answers. This can be done for bulk testing, including random inputs. Also, do bulk, random input, testing for integer arithmetic invariants such as commutativity and associativity for both addition and multiplication. Patricia
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
Question about writing program tests mike3 <mike4ty4@yahoo.com> - 2012-07-04 19:26 -0700
Re: Question about writing program tests mike3 <mike4ty4@yahoo.com> - 2012-07-04 23:33 -0700
Re: Question about writing program tests Jacob Sparre Andersen <sparre@nbi.dk> - 2012-07-05 09:59 +0200
Re: Question about writing program tests mike3 <mike4ty4@yahoo.com> - 2012-07-05 02:53 -0700
Re: Question about writing program tests Patricia Shanahan <pats@acm.org> - 2012-07-05 05:19 -0700
Re: Question about writing program tests "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-07-05 14:51 +0200
csiph-web