2
2
module Codec.Archive.Zim.ParserSpec (main , spec ) where
3
3
4
4
import Control.Monad (forM_ )
5
- import qualified Data.ByteString as B
6
5
import qualified Data.ByteString.Char8 as B8
7
6
import qualified Data.ByteString.Lazy as BL
8
- import qualified Data.ByteString.Lazy.Char8 as BL8
9
- import Data.Char (ord )
10
7
import Data.Maybe (fromJust , isJust )
11
8
import System.IO (Handle , openBinaryFile , IOMode (ReadMode ))
12
9
@@ -16,6 +13,7 @@ import Test.Hspec
16
13
17
14
import Codec.Archive.Zim.Parser
18
15
16
+ testSmallFilePath :: FilePath
19
17
testSmallFilePath = " test/wikipedia_en_ray_charles_2015-06.zim"
20
18
21
19
main :: IO ()
@@ -32,27 +30,27 @@ spec = do
32
30
describe " zim" $ do
33
31
beforeAll setup $ do
34
32
35
- it " can open Ray Charles ZIM" $ \ (smallZim, small ) -> do
33
+ it " can open Ray Charles ZIM" $ \ (smallZim, _ ) -> do
36
34
zimMagicNumber smallZim `shouldBe` 72173914
37
35
38
- it " can get version" $ \ (smallZim, small ) -> do
36
+ it " can get version" $ \ (smallZim, _ ) -> do
39
37
zimVersion smallZim `shouldBe` 5
40
38
41
- it " can get article count" $ \ (smallZim, small ) -> do
39
+ it " can get article count" $ \ (smallZim, _ ) -> do
42
40
zimArticleCount smallZim `shouldBe` 458
43
41
44
- it " can get cluster count" $ \ (smallZim, small ) -> do
42
+ it " can get cluster count" $ \ (smallZim, _ ) -> do
45
43
zimClusterCount smallZim `shouldBe` 215
46
44
47
45
it " can parse MIME list" $ \ (smallZim, small) -> do
48
46
mimeList <- getZimMimeList smallZim small
49
47
mimeList ! 0 `shouldBe` " application/javascript"
50
48
bounds mimeList `shouldBe` (0 , 9 )
51
49
52
- it " can get main page" $ \ (smallZim, small ) -> do
50
+ it " can get main page" $ \ (smallZim, _ ) -> do
53
51
zimMainPage smallZim `shouldBe` Just 238
54
52
55
- it " can get main page URL" $ \ (smallZim, small) -> do
53
+ it " can get main page URL" $ \ _ -> do
56
54
url <- getZimMainPageUrl testSmallFilePath
57
55
url `shouldBe` Just " A/index.htm"
58
56
@@ -62,8 +60,6 @@ spec = do
62
60
zimDeUrl de `shouldBe` " favicon"
63
61
64
62
it " can lookup directory entry by Title index" $ \ (smallZim, small) -> do
65
- de <- getZimDirEntByTitleIndex smallZim small 4
66
- zimDeTitle de `shouldBe` " A Fool for You"
67
63
de <- getZimDirEntByTitleIndex smallZim small 3
68
64
zimDeTitle de `shouldBe` " (The Night Time Is) The Right Time"
69
65
zimDeNamespace de `shouldBe` ' A'
@@ -128,7 +124,7 @@ spec = do
128
124
res <- searchZimDirEntByUrl smallZim small url
129
125
res `shouldBe` Nothing
130
126
131
- it " can get (mimetype, content)" $ \ (smallZim, small) -> do
127
+ it " can get (mimetype, content)" $ \ _ -> do
132
128
res <- getZimUrlContent testSmallFilePath " A/index.htm"
133
129
res `shouldSatisfy` isJust
134
130
let Just (m, c) = res
@@ -148,7 +144,7 @@ spec = do
148
144
de <- getZimDirEntByUrlIndex hdr hdl i
149
145
let url = zimDeUrl de
150
146
bs <- getZimContentByUrlIndex hdr hdl i
151
- (url, bs) `shouldSatisfy` (\ (u , b) -> BL. length b > 0 )
147
+ (url, bs) `shouldSatisfy` (\ (_ , b) -> BL. length b > 0 )
152
148
153
149
it " can search all URLs" $ \ (smallZim, small) -> do
154
150
deList <- mapM (getZimDirEntByUrlIndex smallZim small) [0 .. zimArticleCount smallZim - 1 ]
0 commit comments