Exemplo n.º 1
0
 def test_in_bounds_q_no_zero(self, q: ElementModQ):
     self.assertTrue(q.is_in_bounds_no_zero())
     self.assertFalse(ZERO_MOD_Q.is_in_bounds_no_zero())
     self.assertFalse(
         int_to_q_unchecked(q.to_int() + Q).is_in_bounds_no_zero())
     self.assertFalse(
         int_to_q_unchecked(q.to_int() - Q).is_in_bounds_no_zero())
Exemplo n.º 2
0
 def test_in_bounds_q(self, q: ElementModQ):
     self.assertTrue(q.is_in_bounds())
     too_big = q.to_int() + Q
     too_small = q.to_int() - Q
     self.assertFalse(int_to_q_unchecked(too_big).is_in_bounds())
     self.assertFalse(int_to_q_unchecked(too_small).is_in_bounds())
     self.assertEqual(None, int_to_q(too_big))
     self.assertEqual(None, int_to_q(too_small))
Exemplo n.º 3
0
    def testPsNotEqualToQs(self, q: ElementModQ, q2: ElementModQ):
        p = int_to_p_unchecked(q.to_int())
        p2 = int_to_p_unchecked(q2.to_int())

        # same value should imply they're equal
        self.assertEqual(p, q)
        self.assertEqual(q, p)

        if q.to_int() != q2.to_int():
            # these are genuinely different numbers
            self.assertNotEqual(q, q2)
            self.assertNotEqual(p, p2)
            self.assertNotEqual(q, p2)
            self.assertNotEqual(p, q2)

        # of course, we're going to make sure that a number is equal to itself
        self.assertEqual(p, p)
        self.assertEqual(q, q)
Exemplo n.º 4
0
 def test_large_values_rejected_by_int_to_q(self, q: ElementModQ):
     oversize = q.to_int() + Q
     self.assertEqual(None, int_to_q(oversize))