aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Readers/FB2.hs
diff options
context:
space:
mode:
authorYan Pashkovsky <Yanpas@users.noreply.github.com>2018-05-09 19:48:34 +0300
committerGitHub <noreply@github.com>2018-05-09 19:48:34 +0300
commita337685fe0ab9c63b9456f27787bbe4f0d785a94 (patch)
treee9fc4dfc0802f8acd97f06a8cc8d7c89b5a988ab /test/Tests/Readers/FB2.hs
parent8e9973b9f761262b6871206f741ac3f2a25aa6bb (diff)
parent5f33d2e0cd9f19566904c93be04f586de811dd75 (diff)
downloadpandoc-a337685fe0ab9c63b9456f27787bbe4f0d785a94.tar.gz
Merge branch 'master' into groff_reader
Diffstat (limited to 'test/Tests/Readers/FB2.hs')
-rw-r--r--test/Tests/Readers/FB2.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Tests/Readers/FB2.hs b/test/Tests/Readers/FB2.hs
new file mode 100644
index 000000000..9b2983d57
--- /dev/null
+++ b/test/Tests/Readers/FB2.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+
+module Tests.Readers.FB2 (tests) where
+
+import Prelude
+import Test.Tasty
+import Tests.Helpers
+import Test.Tasty.Golden (goldenVsString)
+import qualified Data.ByteString as BS
+import Text.Pandoc
+import Text.Pandoc.UTF8 (toText, fromTextLazy)
+import Data.Text (Text)
+import Data.Text.Lazy (fromStrict)
+import System.FilePath (replaceExtension)
+
+fb2ToNative :: Text -> Text
+fb2ToNative = purely (writeNative def{ writerTemplate = Just "" }) . purely (readFB2 def)
+
+fb2Test :: TestName -> FilePath -> TestTree
+fb2Test name path = goldenVsString name native (fromTextLazy . fromStrict . fb2ToNative . toText <$> BS.readFile path)
+ where native = replaceExtension path ".native"
+
+tests :: [TestTree]
+tests = [ fb2Test "Emphasis" "fb2/reader/emphasis.fb2"
+ , fb2Test "Titles" "fb2/reader/titles.fb2"
+ , fb2Test "Epigraph" "fb2/reader/epigraph.fb2"
+ , fb2Test "Poem" "fb2/reader/poem.fb2"
+ , fb2Test "Meta" "fb2/reader/meta.fb2"
+ ]