X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/a70a5a8079d70084c6c630071f22585228b2107f..7032ee7c4d3ed206be5b972a9274dab27bbd2936:/t/t-mp.py?ds=sidebyside diff --git a/t/t-mp.py b/t/t-mp.py index a1dd657..24e80cd 100644 --- a/t/t-mp.py +++ b/t/t-mp.py @@ -154,6 +154,14 @@ class TestMP (U.TestCase): while z == z + 1: z *= 2.0 me.assertNotEqual(C.MP(int(z)) + 1, z) + def test_strconv(me): + x, y = C.MP(169), "24" + for fn in [T.add, T.sub]: + me.assertRaises(TypeError, fn, x, y) + me.assertRaises(TypeError, fn, y, x) + me.assertEqual(x*y, 169*"24") + me.assertEqual(y*x, 169*"24") + def test_bits(me): x, y, zero = C.MP(169), C.MP(-24), C.MP(0) me.assertTrue(x.testbit(0)) @@ -396,6 +404,7 @@ class TestGF (U.TestCase): me.assertEqual(C.GF(E(1, 4)), C.GF(1)) me.assertRaises(TypeError, C.GF, E()) + me.assertNotEqual(x, 5) # no implicit conversion to int me.assertEqual(int(x), 5) y = C.GF(0x4eeb684a0954ec4ceb255e3e9778d41) me.assertEqual(type(int(y)), T.long)