Ejemplo n.º 1
0
 def test_error_for_smallest_if_min_is_more_than_max(self):
     with self.assertRaisesWithMessage(ValueError):
         value, factors = smallest_palindrome(min_factor=10000,
                                              max_factor=1)
Ejemplo n.º 2
0
 def test_smallest_palindrome_from_four_digit_factors(self):
     value, factors = smallest_palindrome(min_factor=1000, max_factor=9999)
     self.assertEqual(value, 1002001)
     self.assertFactorsEqual(factors, {(1001, 1001)})
Ejemplo n.º 3
0
 def test_empty_for_smallest_palindrome_if_none_in_range(self):
     with self.assertRaisesWithMessage(ValueError):
         value, factors = smallest_palindrome(min_factor=1002,
                                              max_factor=1003)
Ejemplo n.º 4
0
 def test_smallest_palindrome_from_single_digit_factors(self):
     value, factors = smallest_palindrome(min_factor=1, max_factor=9)
     self.assertEqual(value, 1)
     self.assertFactorsEqual(factors, {(1, 1)})
Ejemplo n.º 5
0
 def test_smallest_palindrome_from_double_digit_factors(self):
     value, factors = smallest_palindrome(min_factor=10, max_factor=99)
     self.assertEqual(value, 121)
     self.assertFactorsEqual(factors, {(11, 11)})
Ejemplo n.º 6
0
 def test_smallest_palindrome_from_triple_digit_factors(self):
     value, factors = smallest_palindrome(max_factor=999, min_factor=100)
     self.assertEqual(value, 10201)
     self.assertEqual(set(factors), {101, 101})
Ejemplo n.º 7
0
 def test_empty_for_smallest_palindrome_if_none_in_range(self):
     value, factors = smallest_palindrome(min_factor=1002, max_factor=1003)
     self.assertIsNone(value)
     self.assertEqual(factors, [])
Ejemplo n.º 8
0
 def test_error_for_smallest_if_min_is_more_than_max(self):
     with self.assertRaisesWithMessage(ValueError):
         value, factors = smallest_palindrome(min_factor=10000,
                                              max_factor=1)
Ejemplo n.º 9
0
 def test_smallest_palindrome_from_double_digit_factors(self):
     value, factors = smallest_palindrome(max_factor=99, min_factor=10)
     self.assertEqual(value, 121)
     self.assertEqual(set(factors), {11})
Ejemplo n.º 10
0
 def test_empty_for_smallest_palindrome_if_none_in_range(self):
     value, factors = smallest_palindrome(min_factor=1002, max_factor=1003)
     self.assertIsNone(value)
     self.assertFactorsEqual(factors, [])
Ejemplo n.º 11
0
 def test_smallest_palindrome_from_four_digit_factors(self):
     value, factors = smallest_palindrome(min_factor=1000, max_factor=9999)
     self.assertEqual(value, 1002001)
     self.assertFactorsEqual(factors, {(1001, 1001)})
Ejemplo n.º 12
0
 def test_smallest_palindrome_from_double_digit_factors(self):
     value, factors = smallest_palindrome(min_factor=10, max_factor=99)
     self.assertEqual(value, 121)
     self.assertFactorsEqual(factors, {(11, 11)})
Ejemplo n.º 13
0
 def test_smallest_palindrome_from_single_digit_factors(self):
     value, factors = smallest_palindrome(min_factor=1, max_factor=9)
     self.assertEqual(value, 1)
     self.assertFactorsEqual(factors, {(1, 1)})
Ejemplo n.º 14
0
 def test_empty_for_smallest_palindrome_if_none_in_range(self):
     with self.assertRaisesWithMessage(ValueError):
         value, factors = smallest_palindrome(min_factor=1002,
                                              max_factor=1003)