summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYesudeep Mangalapilly <yesudeep@gmail.com>2011-08-11 12:03:37 +0530
committerYesudeep Mangalapilly <yesudeep@gmail.com>2011-08-11 12:03:37 +0530
commita5673890cec3d7518726b15d4cecc17c0b55aa4a (patch)
tree49e3c5294d511520ca12ef8a5b9df29dd6d2a8ca /tests
parent7d73cf4398345824eaadf47e31f9c500c612a8b7 (diff)
downloadrsa-a5673890cec3d7518726b15d4cecc17c0b55aa4a.tar.gz
Adds speed tests for int2bytes and old_int2bytes.
* In the following tests, the first speed test for each version of Python checked is the new implementation and the second is the old implementation. $ ./speed.sh int2bytes speed test python2.5 1000 loops, best of 3: 315 usec per loop 100 loops, best of 3: 4.87 msec per loop python2.6 10000 loops, best of 3: 170 usec per loop 100 loops, best of 3: 3.34 msec per loop python2.7 10000 loops, best of 3: 169 usec per loop 100 loops, best of 3: 2.8 msec per loop python3.2 10000 loops, best of 3: 169 usec per loop 100 loops, best of 3: 3.16 msec per loop
Diffstat (limited to 'tests')
-rw-r--r--tests/test_transform.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/test_transform.py b/tests/test_transform.py
index ecc1a30..9bd3c6d 100644
--- a/tests/test_transform.py
+++ b/tests/test_transform.py
@@ -3,7 +3,7 @@
import unittest2
from rsa._compat import b
-from rsa.transform import int2bytes
+from rsa.transform import int2bytes, old_int2bytes
class Test_integer_to_bytes(unittest2.TestCase):
@@ -12,13 +12,21 @@ class Test_integer_to_bytes(unittest2.TestCase):
b('\x00\x00\x07[\xcd\x15'))
self.assertEqual(int2bytes(123456789, 7),
b('\x00\x00\x00\x07[\xcd\x15'))
+ self.assertEqual(old_int2bytes(123456789, 6),
+ b('\x00\x00\x07[\xcd\x15'))
+ self.assertEqual(old_int2bytes(123456789, 7),
+ b('\x00\x00\x00\x07[\xcd\x15'))
def test_raises_OverflowError_when_chunk_size_is_insufficient(self):
self.assertRaises(OverflowError, int2bytes, 123456789, 3)
self.assertRaises(OverflowError, int2bytes, 299999999999, 4)
+ self.assertRaises(OverflowError, old_int2bytes, 123456789, 3)
+ self.assertRaises(OverflowError, old_int2bytes, 299999999999, 4)
def test_raises_ValueError_when_negative_integer(self):
self.assertRaises(ValueError, int2bytes, -1)
+ self.assertRaises(ValueError, old_int2bytes, -1)
def test_raises_TypeError_when_not_integer(self):
self.assertRaises(TypeError, int2bytes, None)
+ self.assertRaises(TypeError, old_int2bytes, None)