aboutsummaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Command.hs4
-rw-r--r--test/Tests/Old.hs5
-rw-r--r--test/Tests/Readers/FB2.hs2
-rw-r--r--test/Tests/Readers/RTF.hs48
4 files changed, 55 insertions, 4 deletions
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs
index 539be1a1a..c197fd11f 100644
--- a/test/Tests/Command.hs
+++ b/test/Tests/Command.hs
@@ -96,7 +96,7 @@ dropPercent xs = xs
runCommandTest :: FilePath -> FilePath -> Int -> String -> TestTree
runCommandTest testExePath fp num code =
- goldenTest testname getExpected getActual compareValues updateGolden
+ goldenTest testname getExpected getActual compareValues' updateGolden
where
testname = "#" <> show num
codelines = lines code
@@ -109,7 +109,7 @@ runCommandTest testExePath fp num code =
norm = unlines normlines
getExpected = return norm
getActual = snd <$> execTest testExePath cmd input
- compareValues expected actual
+ compareValues' expected actual
| actual == expected = return Nothing
| otherwise = return $ Just $ "--- test/command/" ++ fp ++ "\n+++ " ++
cmd ++ "\n" ++ showDiff (1,1)
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs
index ad9f249c4..4baa16d45 100644
--- a/test/Tests/Old.hs
+++ b/test/Tests/Old.hs
@@ -175,7 +175,7 @@ tests pandocPath =
"tikiwiki-reader.tikiwiki" "tikiwiki-reader.native" ]
, testGroup "other writers" $ map (\f -> testGroup f $ writerTests' f)
[ "opendocument" , "context" , "texinfo", "icml", "tei"
- , "man" , "plain" , "rtf", "org", "asciidoc", "asciidoctor"
+ , "man" , "plain" , "asciidoc", "asciidoctor"
, "xwiki", "zimwiki"
]
, testGroup "writers-lang-and-dir"
@@ -207,7 +207,10 @@ tests pandocPath =
, testGroup "org"
[ test' "reader" ["-r", "org", "-w", "native", "-s"]
"org-select-tags.org" "org-select-tags.native"
+ , testGroup "writer" $ writerTests' "org"
]
+ , testGroup "rtf"
+ [ testGroup "writer" $ writerTests' "rtf" ]
, testGroup "ipynb"
[ test' "reader" ["-f", "ipynb-raw_html-raw_tex+raw_attribute",
"-t", "native", "-s"]
diff --git a/test/Tests/Readers/FB2.hs b/test/Tests/Readers/FB2.hs
index 42054a235..d540f8b6a 100644
--- a/test/Tests/Readers/FB2.hs
+++ b/test/Tests/Readers/FB2.hs
@@ -7,7 +7,7 @@
Stability : alpha
Portability : portable
-Tests for the EPUB mediabag.
+Tests for the FB2 reader.
-}
module Tests.Readers.FB2 (tests) where
diff --git a/test/Tests/Readers/RTF.hs b/test/Tests/Readers/RTF.hs
new file mode 100644
index 000000000..2a741bba8
--- /dev/null
+++ b/test/Tests/Readers/RTF.hs
@@ -0,0 +1,48 @@
+{- |
+ Module : Tests.Readers.RTF
+ Copyright : © 2021 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : jgm@berkeley.edu
+ Stability : alpha
+ Portability : portable
+
+Tests for the RTF reader.
+-}
+module Tests.Readers.RTF (tests) where
+
+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, fromStringLazy)
+import Data.Text (Text, unpack)
+import System.FilePath (replaceExtension, (</>), (<.>))
+
+rtfToNative :: Text -> Text
+rtfToNative =
+ purely (writeNative def{ writerTemplate = Just mempty }) .
+ purely (readRTF def)
+
+rtfTest :: TestName -> TestTree
+rtfTest name = goldenVsString name native
+ (fromStringLazy . filter (/='\r') . unpack . rtfToNative . toText
+ <$> BS.readFile path)
+ where native = replaceExtension path ".native"
+ path = "rtf" </> name <.> "rtf"
+
+tests :: [TestTree]
+tests = map rtfTest [ "footnote"
+ , "accent"
+ , "unicode"
+ , "image"
+ , "link"
+ , "heading"
+ , "formatting"
+ , "list_simple"
+ , "list_complex"
+ , "bookmark"
+ , "table_simple"
+ ]
+