Beispiel #1
0
    def test_text_init(self):
        "Test the Taxicab object creation from text"

        # 1. Create Taxicab object from text
        myobj = taxicab.Taxicab(text=aoc_01.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 1)
        self.assertEqual(myobj.instructions, ['R2', 'L3'])
        self.assertEqual(myobj.location, [0, 0])
        self.assertEqual(myobj.facing, "N")

        # 3. Check methods
        self.assertEqual(myobj.from_start(), 0)
        myobj.follow_instructions()
        self.assertEqual(myobj.location, [2, 3])
        self.assertEqual(myobj.facing, "N")
        self.assertEqual(myobj.from_start(), 5)

        # 4. Example 2
        myobj = taxicab.Taxicab(text=aoc_01.from_text(EXAMPLE_TWO))
        myobj.follow_instructions()
        self.assertEqual(myobj.from_start(), 2)
        self.assertEqual(myobj.location, [0, -2])

        # 5. Example 3
        myobj = taxicab.Taxicab(text=aoc_01.from_text(EXAMPLE_THREE))
        myobj.follow_instructions()
        self.assertEqual(myobj.from_start(), 12)

        # 6. Example 4
        myobj = taxicab.Taxicab(text=aoc_01.from_text(EXAMPLE_FOUR))
        myobj.find_hq()
        self.assertEqual(myobj.from_start(), 4)
Beispiel #2
0
    def test_part_two(self):
        "Test part two example of Lisp object"

        # 1. Create Lisp object from text
        myobj = lisp.Lisp(part2=True, text=aoc_01.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
Beispiel #3
0
    def test_part_one(self):
        "Test part one example of Lisp object"

        # 1. Create Lisp object from text
        myobj = lisp.Lisp(text=aoc_01.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
Beispiel #4
0
    def test_text_init(self):
        "Test the Lisp object creation from text"

        # 1. Create Lisp object from text
        myobj = lisp.Lisp(text=aoc_01.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 7)
    def test_text_init(self):
        "Test the Report object creation from text"

        # 1. Create Report object from text
        myobj = report.Report(text=aoc_01.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 6)
        self.assertEqual(len(myobj.numbers), 6)
Beispiel #6
0
    def test_text_init(self):
        """Test Captcha object creation from text"""

        # 1. Create Captcha object from text
        mycap = captcha.Captcha(text=aoc_01.from_text(P1_EXAMPLE_TEXT)[0])

        # 2. Make sure it has the specified values
        self.assertEqual(mycap.text, "1122")
        self.assertEqual(mycap.part2, False)
        self.assertEqual(mycap.offset, 1)

        # 3. Check methods
        self.assertEqual(mycap.solve(), 3)
        self.assertEqual(mycap.re_solve(), 3)
Beispiel #7
0
    def test_part_two_text_init(self):
        """Test Captcha object creation from text"""

        # 1. Create Captcha object from text
        mycap = captcha.Captcha(part2=True,
                                text=aoc_01.from_text(P2_EXAMPLE_TEXT)[0])

        # 2. Make sure it has the specified values
        self.assertEqual(mycap.text, "1212")
        self.assertEqual(mycap.part2, True)
        self.assertEqual(mycap.offset, 2)

        # 3. Check methods
        self.assertEqual(mycap.solve(verbose=False), 6)
    def test_text_init(self):
        "Test the Sonar object creation from text"

        # 1. Create Sonar object from text
        myobj = sonar.Sonar(text=aoc_01.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.more_than_previous(), 7)
        self.assertEqual(myobj.do_windows(window=1), 7)
        self.assertEqual(myobj.do_windows(), 5)