From 1927bc9aac0e822bd6179323e00fe38bee5a2cf3 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 26 Apr 2018 22:33:18 +0300 Subject: Add FB2 reader (#4539) --- test/Tests/Readers/FB2.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/Tests/Readers/FB2.hs (limited to 'test/Tests/Readers/FB2.hs') 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" + ] -- cgit v1.2.3