Beispiel #1
0
    def test_turnRight(self):
        mc = MarsCarDemo()
        pos = {"x": 3, "y": 4, "fc": 'N', "rip": None}
        mc.setMarsCarPos(pos)

        tar_pos = {"x": 3, "y": 4, "fc": 'E', "rip": None}
        mc.turnRight(pos)
        self.assertEqual(mc.getMarsCarPos(), tar_pos)
Beispiel #2
0
    def test_moveStep_rip(self):
        mc = MarsCarDemo()
        xy = {"xMax": 4, "yMax": 4}
        mc.setXyMax(xy)
        pos = {"x": 3, "y": 4, "fc": 'N', "rip": None}
        mc.setMarsCarPos(pos)

        # print(mc.getMarsCarPos())
        mc.moveStep(pos)
        # print(mc.getMarsCarPos())
        self.assertEqual(mc.getMarsCarPos()["rip"], 'RIP')
Beispiel #3
0
    def test_moveStep_alive(self):
        mc = MarsCarDemo()
        xy = {"xMax": 5, "yMax": 5}
        mc.setXyMax(xy)
        pos = {"x": 3, "y": 4, "fc": 'E', "rip": None}
        mc.setMarsCarPos(pos)

        tar_pos = copy.deepcopy(pos)
        tar_pos['x'] += 1
        # print(mc.getMarsCarPos())
        mc.moveStep(pos)
        # print(mc.getMarsCarPos())
        self.assertEqual(mc.getMarsCarPos(), tar_pos)
Beispiel #4
0
 def test_setMarsCarPos(self):
     mc = MarsCarDemo()
     pos = {"x": 3, "y": 4, "fc": None, "rip": None}
     mc.setMarsCarPos(pos)
     self.assertEqual(mc.getMarsCarPos(), pos)