Commit graph

12 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
cddb6c0e02 Rewrite the zero shortcut tests to avoid dropping a const qualifier. 2014-12-30 20:03:58 +00:00
Dag-Erling Smørgrav
3904e809b2 Add two test cases for shortcut logic used when one operand is zero and
the other is also the target.
2014-12-30 19:57:07 +00:00
Dag-Erling Smørgrav
241f524238 Fix a bogus t_malloc_fail in one of the mpi_add_abs() tests.
Add several subtraction test cases and modify some others to better
exercise the carry logic, which is far more complex for subtraction than
for addition.

Add test cases where the target is the same MPI as one or both operands.
2014-12-30 19:48:57 +00:00
Dag-Erling Smørgrav
8d0e24dee7 Remove the "trailing garbage" version of the mpi_cmp() test. It would
be better to systematically pad MPIs used in all tests with garbage.

Greatly expand the number of mpi_cmp() tests to cover all possible
combinations of same or different sign, same or different msb and same
or different magnitude.
2014-12-30 17:00:56 +00:00
Dag-Erling Smørgrav
f18b915b67 Fix the "x = a + b" allocation failure test. Since a and b were
equal, mpi_sub_abs() would return early and the test would never
exercise the mpi_grow() call which is intended to fail.
2014-12-30 16:46:44 +00:00
Dag-Erling Smørgrav
2027ce33e7 Add tests for the off-by-one bug we just fixed in mpi_cmp_abs(). 2014-12-30 16:38:47 +00:00
Dag-Erling Smørgrav
e21452d0c7 Add a few tests for subtraction. They're not particularly well thought
out, because currently subtraction does not work at all, but they work
well enough in the sense that they fail with the current implementation.
2014-12-30 11:19:02 +00:00
Dag-Erling Smørgrav
03867777c6 Add numerous tests, mostly for allocation failures and edge conditions.
Add a t_compare_mpi() predicate which checks that two MPIs have the same
value (but not necessarily the exact same representation).
Clean up and improve existing tests.
2014-12-29 23:54:02 +00:00
Dag-Erling Smørgrav
1fbf2cf156 It appears that gcc does not accept partial struct initialization. Add
a CRYB_MPI_ZERO macro that expands to an all-zeroes initializer.
2014-10-30 12:46:01 +00:00
Dag-Erling Smørgrav
3be915b8d7 Previous commit was incomplete. Add missing prototypes and a test case. 2014-08-14 18:42:52 +00:00
Dag-Erling Smørgrav
885c586ce9 Add a test function for comparison operators (but no test cases yet).
Consistently destroy MPIs after use.
2014-08-14 18:26:06 +00:00
Dag-Erling Smørgrav
be31515f5e Start of a multiple-precision integer arithmetic library. 2014-08-12 07:30:31 +00:00