예제 #1
0
    def test_part_one(self):
        "Test part one example of Bingo object"

        # 1. Create Bingo object from text
        myobj = bingo.Bingo(text=aoc_04.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
예제 #2
0
    def test_part_two(self):
        "Test part two example of Bingo object"

        # 1. Create Bingo object from text
        myobj = bingo.Bingo(part2=True, text=aoc_04.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
예제 #3
0
    def test_text_init(self):
        "Test the Scanner object creation from text"

        # 1. Create Scanner object from text
        myobj = scanner.Scanner(text=aoc_04.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 4)
        self.assertEqual(len(myobj.passports), 4)
예제 #4
0
    def test_text_init(self):
        "Test the Bingo object creation from text"

        # 1. Create Bingo object from text
        myobj = bingo.Bingo(text=aoc_04.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 16)
        self.assertEqual(len(myobj.numbers), 27)
        self.assertEqual(len(myobj.cards), 3)
예제 #5
0
    def test_text_init(self):
        "Test the List object creation from text"

        # 1. Create List object from text
        myobj = list.List(text=aoc_04.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 4)

        # 3. Test methods
        self.assertEqual(myobj.total_valid(), 1514)
예제 #6
0
    def test_text_init(self):
        "Test the Miner object creation from text"

        # 1. Create Miner object from text
        myobj = miner.Miner(text=aoc_04.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 1)

        # 3. Check methods
        self.assertTrue(myobj.md5_number(609043).startswith('000001dbbfa'))
    def test_text_init(self):
        """Test PassPhrases creation from text"""

        # 1. Create default PassPhrases object
        mypass = passphrases.PassPhrases(
            text=aoc_04.from_text(P1_EXAMPLES_TEXT))

        # 2. Make sure it has the default values
        self.assertEqual(mypass.part2, False)
        self.assertEqual(len(mypass.phrases), 3)

        # 3. Check methods
        self.assertEqual(mypass.knt_valid(), 2)
예제 #8
0
    def test_text_init(self):
        "Test the Card object creation from text"

        # 1. Create Card object from text
        myobj = card.Card(text=aoc_04.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 5)
        self.assertEqual(len(myobj.numbers), 25)
        self.assertEqual(len(myobj.called), 25)
        self.assertEqual(myobj.last, None)
        self.assertEqual(myobj.has_won, False)

        # 3. Check methods
        self.assertEqual(myobj.covered(), 0)
        self.assertEqual(myobj.call(7), False)
        self.assertEqual(myobj.last, 7)
        self.assertEqual(myobj.covered(), 1)
        self.assertEqual(myobj.call(4), False)
        self.assertEqual(myobj.covered(), 2)
        self.assertEqual(myobj.call(9), False)
        self.assertEqual(myobj.call(5), False)
        self.assertEqual(myobj.call(11), False)
        self.assertEqual(myobj.call(17), False)
        self.assertEqual(myobj.last, 17)
        self.assertEqual(myobj.call(23), False)
        self.assertEqual(myobj.call(2), False)
        self.assertEqual(myobj.call(0), False)
        self.assertEqual(myobj.call(14), False)
        self.assertEqual(myobj.call(21), False)
        self.assertEqual(myobj.has_won, False)
        self.assertEqual(myobj.call(24), True)
        self.assertEqual(myobj.has_won, True)
        self.assertEqual(myobj.covered(), 12)
        self.assertEqual(myobj.score(), 4512)