Example #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)
Example #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)})
Example #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)
Example #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)})
Example #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)})
Example #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})
Example #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, [])
Example #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)
Example #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})
Example #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, [])
Example #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)})
Example #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)})
Example #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)})
 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)