[svn] gcry - r1434 - branches/LIBGCRYPT-1-4-BRANCH/tests
svn author wk
cvs at cvs.gnupg.org
Thu Jun 10 11:06:47 CEST 2010
Author: wk
Date: 2010-06-10 11:06:46 +0200 (Thu, 10 Jun 2010)
New Revision: 1434
Modified:
branches/LIBGCRYPT-1-4-BRANCH/tests/ChangeLog
branches/LIBGCRYPT-1-4-BRANCH/tests/t-mpi-bit.c
Log:
Fix a test. Reported by Jeff Johnson.
Modified: branches/LIBGCRYPT-1-4-BRANCH/tests/ChangeLog
===================================================================
--- branches/LIBGCRYPT-1-4-BRANCH/tests/ChangeLog 2010-06-10 09:05:42 UTC (rev 1433)
+++ branches/LIBGCRYPT-1-4-BRANCH/tests/ChangeLog 2010-06-10 09:06:46 UTC (rev 1434)
@@ -1,3 +1,7 @@
+2010-06-10 Werner Koch <wk at g10code.com>
+
+ * t-mpi-bit.c (mpi2bitstr_nlz): Handle case for LENGTH==0.
+
2009-01-22 Werner Koch <wk at g10code.com>
* cavs_tests.sh: Pass option -D to driver if required.
Modified: branches/LIBGCRYPT-1-4-BRANCH/tests/t-mpi-bit.c
===================================================================
--- branches/LIBGCRYPT-1-4-BRANCH/tests/t-mpi-bit.c 2010-06-10 09:05:42 UTC (rev 1433)
+++ branches/LIBGCRYPT-1-4-BRANCH/tests/t-mpi-bit.c 2010-06-10 09:06:46 UTC (rev 1434)
@@ -108,13 +108,20 @@
{
char *p, *buf;
size_t length = gcry_mpi_get_nbits (a);
-
- buf = p = xmalloc (length + 1);
- while (length-- > 1)
- *p++ = gcry_mpi_test_bit (a, length) ? '1':'0';
- *p++ = gcry_mpi_test_bit (a, 0) ? '1':'0';
+
+ if (!length)
+ {
+ buf = p = xmalloc (2);
+ *p++ = '0';
+ }
+ else
+ {
+ buf = p = xmalloc (length + 1);
+ while (length-- > 1)
+ *p++ = gcry_mpi_test_bit (a, length) ? '1':'0';
+ *p++ = gcry_mpi_test_bit (a, 0) ? '1':'0';
+ }
*p = 0;
-
return buf;
}
@@ -190,7 +197,7 @@
gcry_mpi_release (a);
}
-/* Check that the shifting actually works for an amount larger than
+/* Check that right shifting actually works for an amount larger than
the number of bits per limb. */
static void
test_rshift (int pass)
@@ -249,7 +256,7 @@
gcry_mpi_release (a);
}
-/* Check that the left shifting. */
+/* Check that left shifting works correctly. */
static void
test_lshift (int pass)
{
More information about the Gnupg-commits
mailing list