def test_part_one(self):
        "Test part one example of License object"

        # 1. Create License object from text
        myobj = license.License(text=aoc_08.from_text(PART_ONE_TEXT))

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

        # 1. Create License object from text
        myobj = license.License(part2=True,
                                text=aoc_08.from_text(PART_TWO_TEXT))

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

        # 1. Create License object from text
        myobj = license.License(text=aoc_08.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 1)
示例#4
0
    def test_part_one(self):
        "Test part one example of Display object"

        # 1. Create Display object from text
        myobj = display.Display(text=aoc_08.from_text(PART_ONE_TEXT),
                                wide=7,
                                tall=3)

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

        # 1. Create Display object from text
        myobj = display.Display(part2=True,
                                text=aoc_08.from_text(PART_TWO_TEXT),
                                wide=7,
                                tall=3)

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
示例#6
0
    def test_text_init(self):
        "Test the Patterns object creation from text"

        # 1. Create Patterns object from text
        myobj = patterns.Patterns(text=aoc_08.from_text(EXAMPLE_TEXT))

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

        # 3. Check methods
        self.assertEqual(myobj.one_four_seven_eight(), 26)
    def test_text_init(self):
        """Test Instructs creation from text"""

        # 1. Create Jumps object from text
        myinsts = instructions.Instructions(
            text=aoc_08.from_text(P1_EXAMPLES_TEXT))

        # 2. Make sure it has the specified values
        self.assertEqual(myinsts.part2, False)
        self.assertEqual(len(myinsts.insts), 4)

        # 3. Check methods
        self.assertEqual(myinsts.largest(verbose=False), 1)
    def test_part_two(self):
        """Test Discs creation from text"""

        # 1. Create Jumps object from text
        myinsts = instructions.Instructions(
            text=aoc_08.from_text(P1_EXAMPLES_TEXT), part2=True)

        # 2. Make sure it has the specified values
        self.assertEqual(myinsts.part2, True)
        self.assertEqual(len(myinsts.insts), 4)

        # 3. Check methods
        self.assertEqual(myinsts.largest(verbose=False), 1)

        # 4. Check part two methods
        self.assertEqual(myinsts.highest(verbose=False), 10)
示例#9
0
    def test_text_init(self):
        "Test the Display object creation from text"

        # 1. Create Display object from text
        myobj = display.Display(text=aoc_08.from_text(EXAMPLE_TEXT),
                                wide=7,
                                tall=3)

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 4)
        self.assertEqual(myobj.tall, 3)
        self.assertEqual(myobj.wide, 7)
        self.assertEqual(len(myobj.pixels), 3)
        self.assertEqual(myobj.inst, 0)

        # 3. Check methods
        self.assertEqual(myobj.lit(), 0)
        self.assertEqual(str(myobj), DISPLAY_START)
        self.assertEqual(myobj.one_inst(), True)
        self.assertEqual(myobj.inst, 1)
        self.assertEqual(str(myobj), DISPLAY_ONE)
        self.assertEqual(myobj.lit(), 6)
        self.assertEqual(myobj.one_inst(), True)
        self.assertEqual(myobj.inst, 2)
        self.assertEqual(str(myobj), DISPLAY_TWO)
        self.assertEqual(myobj.lit(), 6)
        self.assertEqual(myobj.one_inst(), True)
        self.assertEqual(myobj.inst, 3)
        self.assertEqual(str(myobj), DISPLAY_THREE)
        self.assertEqual(myobj.lit(), 6)
        self.assertEqual(myobj.one_inst(), True)
        self.assertEqual(myobj.inst, 4)
        self.assertEqual(str(myobj), DISPLAY_FOUR)
        self.assertEqual(myobj.lit(), 6)
        self.assertEqual(myobj.one_inst(), False)
        self.assertEqual(myobj.inst, 4)
        self.assertEqual(str(myobj), DISPLAY_FOUR)
        self.assertEqual(myobj.lit(), 6)
    def test_text_init(self):
        "Test the Literals object creation from text"

        # 1. Create Literals object from text
        myobj = literals.Literals(text=aoc_08.from_text(EXAMPLE_TEXT))

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

        # 3. Check methods
        for indx, text in enumerate(myobj.text):
            print(indx, '<%s>' % text)
            self.assertEqual(myobj.code_size(text), EXAMPLE_CODE_SIZE[indx])
        for indx, text in enumerate(myobj.text):
            print(indx, '<%s>' % text, 'decode <%s>' % eval(text))
            self.assertEqual(myobj.decoded_size(text),
                             EXAMPLE_DECODED_SIZE[indx])
        for indx, text in enumerate(myobj.text):
            print(
                indx, '<%s>' % text,
                'encode <%s>' % text.replace('\\', '\\\\').replace('"', '\\"'))
            self.assertEqual(myobj.encoded_size(text),
                             EXAMPLE_ENCODED_SIZE[indx])