|
| 1 | +import Test.HUnit (Test(TestList), runTestTT, (~=?), Counts(errors, failures)) |
| 2 | +import Utils (stringsFromStatus, Hash(MkHash)) |
| 3 | +import Control.Applicative ((<$>)) |
| 4 | +import System.Exit (exitFailure) |
| 5 | +import Control.Monad (when) |
| 6 | + |
| 7 | +type TestData = (String, String, [Int]) |
| 8 | + |
| 9 | +tests :: [TestData] |
| 10 | +tests = [ |
| 11 | + ("## master...ori/master [ahead 3]\n M", "master", [3,0,0,0,1,0]) |
| 12 | + , |
| 13 | + ("## stat\nM ", "stat", [0,0,1,0,0,0]) |
| 14 | + , |
| 15 | + ("## exp...o/exp [ahead 3, behind 2]\n", "exp", [3,2,0,0,0,0]) |
| 16 | + , |
| 17 | + ("## master\nU \nU \nM \nM \nM ", "master", [0,0,3,2,0,0]) |
| 18 | + , |
| 19 | + ("## HEAD (no branch)\n", ":hash", [0,0,0,0,0,0]) |
| 20 | + , |
| 21 | + ("## master\n M\n M\n M\n??\n", "master", [0,0,0,0,3,1]) |
| 22 | + ] |
| 23 | + |
| 24 | +makeTest :: TestData -> Test |
| 25 | +makeTest (input, branch, numbers) = Just (branch : (show <$> numbers)) ~=? stringsFromStatus (Just $ MkHash "hash") input |
| 26 | + |
| 27 | +main :: IO () |
| 28 | +main = do |
| 29 | + testResult <- runTestTT $ TestList $ makeTest <$> tests |
| 30 | + let some accessor = accessor testResult /= 0 |
| 31 | + when (some errors || some failures) exitFailure |
0 commit comments