~vonfry/maze-escape

ref: 0.1.0.0 maze-escape/test/Spec.hs -rw-r--r-- 777 bytes
4281a0ebVonfry fixup! Merge branch 'develop' 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- |

module Main where

import Test.Hspec
import Game.Maze
import Game.Maze.Data

main :: IO ()
main = hspec $
  describe "Escape from maze" $ do
    it "Case 1" $
      runTestCase case1 `shouldBe` 2
    it "Case 2" $
      runTestCase case2 `shouldBe` 4
    it "Case 3" $
      runTestCase case3 `shouldBe` 4
    it "Case 4" $
      runTestCase case4 `shouldBe` 3

runTestCase :: MazeMap -> Int
runTestCase = length . shortestEscapePath

case1 = MazeMapList [[S]
                    ,[D]]

case2 = MazeMapList [[X, X, S]
                    ,[D, O, O]]

case3 = MazeMapList [[X, X, S]
                    ,[D, O, O]
                    ,[X, O, O]]

case4 = MazeMapList [[X, O, X]
                    ,[X, S, O]
                    ,[O, O, O]
                    ,[O, D, O]]