implemented goalieSearch
This commit is contained in:
parent
2926e28e34
commit
7e19ee072f
|
@ -843,7 +843,8 @@ goalieSearch
|
||||||
-- ^ The list to search
|
-- ^ The list to search
|
||||||
-> [(Int, Goalie)]
|
-> [(Int, Goalie)]
|
||||||
-- ^ The search results with their corresponding index numbers
|
-- ^ The search results with their corresponding index numbers
|
||||||
goalieSearch = undefined
|
goalieSearch sStr = filter (\(_, goalie) -> sStr `isInfixOf` (goalie^.gName)) .
|
||||||
|
zip [0..]
|
||||||
|
|
||||||
-- | Searches a list of goalies for an exact match
|
-- | Searches a list of goalies for an exact match
|
||||||
goalieSearchExact
|
goalieSearchExact
|
||||||
|
|
|
@ -65,6 +65,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
playerIsActiveSpec
|
playerIsActiveSpec
|
||||||
psPointsSpec
|
psPointsSpec
|
||||||
addPlayerStatsSpec
|
addPlayerStatsSpec
|
||||||
|
goalieSearchSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
playerSpec :: Spec
|
playerSpec :: Spec
|
||||||
|
@ -651,6 +652,28 @@ addPlayerStatsSpec = describe "addPlayerStats" $ do
|
||||||
it "should be 9" $
|
it "should be 9" $
|
||||||
s3^.psPMin `shouldBe` 9
|
s3^.psPMin `shouldBe` 9
|
||||||
|
|
||||||
|
goalieSearchSpec :: Spec
|
||||||
|
goalieSearchSpec = describe "goalieSearch" $ do
|
||||||
|
let
|
||||||
|
goalies =
|
||||||
|
[ newGoalie 2 "Joe"
|
||||||
|
, newGoalie 3 "Bob"
|
||||||
|
, newGoalie 5 "Steve"
|
||||||
|
]
|
||||||
|
result n = (n, goalies!!n)
|
||||||
|
|
||||||
|
context "partial match" $
|
||||||
|
it "should return Joe and Steve" $
|
||||||
|
goalieSearch "e" goalies `shouldBe` [result 0, result 2]
|
||||||
|
|
||||||
|
context "no match" $
|
||||||
|
it "should return an empty list" $
|
||||||
|
goalieSearch "x" goalies `shouldBe` []
|
||||||
|
|
||||||
|
context "exact match" $
|
||||||
|
it "should return Steve" $
|
||||||
|
goalieSearch "Bob" goalies `shouldBe` [result 1]
|
||||||
|
|
||||||
joe :: Player
|
joe :: Player
|
||||||
joe = newPlayer 2 "Joe" "center"
|
joe = newPlayer 2 "Joe" "center"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user