* Better Patch for Configfile handling
[opeanno-debian-packaging.git] / tests / pathfinding.py
blob898715bdd397a305549707deadb3122c559eeae2
1 #!/usr/bin/env python
3 # ###################################################
4 # Copyright (C) 2008 The OpenAnno Team
5 # team@openanno.org
6 # This file is part of OpenAnno.
8 # OpenAnno is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the
20 # Free Software Foundation, Inc.,
21 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 # ###################################################
24 import unittest
26 from game.world.pathfinding import findPath
27 from game.util import Point, Rect
29 class TestPathfinding(unittest.TestCase):
31 def testA(self):
32 p = findPath(Point(1,1), Rect(2,2,2,2), [(1,2)])
33 self.assertEqual(p, [(1, 1), (1, 2), (2, 2)])
35 def testB(self):
36 p = findPath(Point(1,1), Rect(2,2,2,2), [(1,2)], diagonal = True)
37 self.assertEqual(p,[(1, 1), (2, 2)])
39 def testC(self):
40 p = findPath(Point(1,1), Rect(3,3,3,3), [(1,2),(2,2),(2,1),(2,3)])
41 self.assertEqual(p, [(1, 1), (1, 2), (2, 2), (2, 3), (3, 3)])
43 def testD(self):
44 p = findPath(Point(1,1), Rect(3,3,5,5), [(1,2),(2,2),(2,1),(2,3)])
45 self.assertEqual(p, [(1, 1), (1, 2), (2, 2), (2, 3), (3, 3)])
47 # missing:
48 # - different source/target formats
49 # - blocked_choords