Exemple #1
0
    def test_is_happy(self):
        for number in range(1, self.HAPPY_NUMBERS[-1] + 1):
            if number in self.HAPPY_NUMBERS:
                self.assertTrue(is_happy(number))
            else:
                self.assertFalse(is_happy(number))

        for number in self.HAPPY_DOUBLES:
            self.assertTrue(is_happy(number))
            self.assertTrue(is_happy(number + 1))

        for number in self.HAPPY_TRIPLES:
            self.assertTrue(is_happy(number))
            self.assertTrue(is_happy(number + 1))
            self.assertTrue(is_happy(number + 2))
Exemple #2
0
 def test_no_unhappy__numbers_up_to_a_point(self):
     for unhappy_number in UNHAPPY_NUMBERS:
         self.assertFalse(solution.is_happy(unhappy_number),
                          '{} is expected to be an unhappy number'.format(
                              unhappy_number))
Exemple #3
0
 def test_no_unhappy__numbers_up_to_a_point(self):
     for unhappy_number in UNHAPPY_NUMBERS:
         self.assertFalse(
             solution.is_happy(unhappy_number),
             '{} is expected to be an unhappy number'.format(
                 unhappy_number))
Exemple #4
0
 def test_all_happy_numbers_up_to_a_point(self):
     for happy_number in HAPPY_NUMBERS:
         self.assertTrue(solution.is_happy(happy_number),
                         '{} is expected to be a happy number'.format(
                             happy_number))
Exemple #5
0
 def test_all_happy_numbers_up_to_a_point(self):
     for happy_number in HAPPY_NUMBERS:
         self.assertTrue(
             solution.is_happy(happy_number),
             '{} is expected to be a happy number'.format(happy_number))