Exemplo n.º 1
0
 def test_invalid_inputs(self):
     with self.assertRaises(ValueError):
         iroot(-1, 5)
     with self.assertRaises(ValueError):
         iroot(4, 0)
     with self.assertRaises(ValueError):
         iroot(-27, -3)
     with self.assertRaises(ValueError):
         iroot(0, 0)
Exemplo n.º 2
0
 def test_large_root(self):
     self.assertEqual(iroot(2**10000, 10000), 2)
     self.assertEqual(iroot(2**10000 - 1, 10000), 1)
Exemplo n.º 3
0
 def test_matches_icbrt(self):
     for n in range(1000):
         self.assertEqual(iroot(n, 3), icbrt(n))
Exemplo n.º 4
0
 def test_fourth_root(self):
     for n in range(1000):
         k = iroot(n, 4)
         self.assertLessEqual(k**4, n)
         self.assertLess(n, (k + 1)**4)
Exemplo n.º 5
0
 def test_first_root(self):
     for n in range(1000):
         self.assertEqual(iroot(n, 1), n)