Пример #1
0
 def test_prime_sum(self):
     # Test the prime_sum function by comparing it to prime_partial_sums.
     it = pyprimes.prime_partial_sums()
     for i in range(100):
         expected = next(it)
         actual = pyprimes.prime_sum(i)
         self.assertEqual(actual, expected)
Пример #2
0
 def test_prime_sum(self):
     # Test the prime_sum function by comparing it to prime_partial_sums.
     it = pyprimes.prime_partial_sums()
     for i in range(100):
         expected = next(it)
         actual = pyprimes.prime_sum(i)
         self.assertEqual(actual, expected)
Пример #3
0
 def test_prime_partial_sums(self):
     it = pyprimes.prime_partial_sums()
     self.assertTrue(it is iter(it))
     # Table of values from http://oeis.org/A007504
     expected = [
         0, 2, 5, 10, 17, 28, 41, 58, 77, 100, 129, 160, 197, 238, 281, 328,
         381, 440, 501, 568, 639, 712, 791, 874, 963, 1060, 1161, 1264,
         1371, 1480, 1593, 1720, 1851, 1988, 2127, 2276, 2427, 2584, 2747,
         2914, 3087, 3266, 3447, 3638, 3831, 4028, 4227, 4438, 4661, 4888
     ]
     actual = [next(it) for _ in range(len(expected))]
     self.assertEqual(actual, expected)
Пример #4
0
 def test_prime_partial_sums(self):
     it = pyprimes.prime_partial_sums()
     self.assertTrue(it is iter(it))
     # Table of values from http://oeis.org/A007504
     expected = [
         0, 2, 5, 10, 17, 28, 41, 58, 77, 100, 129, 160, 197, 238, 281,
         328, 381, 440, 501, 568, 639, 712, 791, 874, 963, 1060, 1161,
         1264, 1371, 1480, 1593, 1720, 1851, 1988, 2127, 2276, 2427,
         2584, 2747, 2914, 3087, 3266, 3447, 3638, 3831, 4028, 4227,
         4438, 4661, 4888]
     actual = [next(it) for _ in range(len(expected))]
     self.assertEqual(actual, expected)