From ae07d5ed490b1d2f8cbb943a8d876a798d57f470 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Tue, 3 Mar 2015 14:37:02 +0300 Subject: Initial tests for writer --- tests/Tests/Writers/Docx.hs | 128 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 tests/Tests/Writers/Docx.hs (limited to 'tests/Tests') diff --git a/tests/Tests/Writers/Docx.hs b/tests/Tests/Writers/Docx.hs new file mode 100644 index 000000000..4a199755d --- /dev/null +++ b/tests/Tests/Writers/Docx.hs @@ -0,0 +1,128 @@ +module Tests.Writers.Docx (tests) where + +import Text.Pandoc.Options +import Text.Pandoc.Readers.Native +import Text.Pandoc.Definition +import Tests.Helpers +import Test.Framework +import Text.Pandoc.Readers.Docx +import Text.Pandoc.Writers.Docx + +type Options = (WriterOptions, ReaderOptions) + +compareOutput :: Options + -> FilePath + -> IO (Pandoc, Pandoc) +compareOutput opts nativeFile = do + nf <- Prelude.readFile nativeFile + df <- writeDocx (fst opts) (readNative nf) + let (p, _) = readDocx (snd opts) df + return (p, readNative nf) + +testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test +testCompareWithOptsIO opts name nativeFile = do + (dp, np) <- compareOutput opts nativeFile + return $ test id name (dp, np) + +testCompareWithOpts :: Options -> String -> FilePath -> Test +testCompareWithOpts opts name nativeFile = + buildTest $ testCompareWithOptsIO opts name nativeFile + +testCompare :: String -> FilePath -> Test +testCompare = testCompareWithOpts def + +tests :: [Test] +tests = [ testGroup "inlines" + [ testCompare + "font formatting" + "docx/inline_formatting_writer.native" + , testCompare + "font formatting with character styles" + "docx/char_styles.native" + , testCompare + "hyperlinks" + "docx/links_writer.native" + , testCompare + "inline image" + "docx/image_no_embed_writer.native" + , testCompare + "inline image in links" + "docx/inline_images_writer.native" + , testCompare + "handling unicode input" + "docx/unicode.native" + , testCompare + "literal tabs" + "docx/tabs.native" + , testCompare + "normalizing inlines" + "docx/normalize.native" + , testCompare + "normalizing inlines deep inside blocks" + "docx/deep_normalize.native" + , testCompare + "move trailing spaces outside of formatting" + "docx/trailing_spaces_in_formatting.native" + , testCompare + "inline code (with VerbatimChar style)" + "docx/inline_code.native" + , testCompare + "inline code in subscript and superscript" + "docx/verbatim_subsuper.native" + ] + , testGroup "blocks" + [ testCompare + "headers" + "docx/headers.native" + , testCompare + "headers already having auto identifiers" + "docx/already_auto_ident.native" + , testCompare + "numbered headers automatically made into list" + "docx/numbered_header.native" + , testCompare + "i18n blocks (headers and blockquotes)" + "docx/i18n_blocks.native" + -- some level problems, look into that + -- , testCompare + -- "lists" + -- "docx/lists.native" + , testCompare + "definition lists" + "docx/definition_list.native" + , testCompare + "custom defined lists in styles" + "docx/german_styled_lists.native" + , testCompare + "footnotes and endnotes" + "docx/notes.native" + , testCompare + "blockquotes (parsing indent as blockquote)" + "docx/block_quotes_parse_indent.native" + , testCompare + "hanging indents" + "docx/hanging_indent.native" + -- tables headers do not survive round-trip, should look into that + -- , testCompare + -- "tables" + -- "docx/tables.native" + -- , testCompare + -- "tables with lists in cells" + -- "docx/table_with_list_cell.native" + , testCompare + "code block" + "docx/codeblock.native" + , testCompare + "dropcap paragraphs" + "docx/drop_cap.native" + ] + , testGroup "metadata" + [ testCompareWithOpts (def,def{readerStandalone=True}) + "metadata fields" + "docx/metadata.native" + , testCompareWithOpts (def,def{readerStandalone=True}) + "stop recording metadata with normal text" + "docx/metadata_after_normal.native" + ] + + ] -- cgit v1.2.3 From a82dedf1ff1b6fe345640843dad653386a8f9bc7 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 8 Mar 2015 03:59:48 +0300 Subject: Lists test --- tests/Tests/Writers/Docx.hs | 8 ++++---- tests/docx/lists_writer.native | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/docx/lists_writer.native (limited to 'tests/Tests') diff --git a/tests/Tests/Writers/Docx.hs b/tests/Tests/Writers/Docx.hs index 4a199755d..a22daadb8 100644 --- a/tests/Tests/Writers/Docx.hs +++ b/tests/Tests/Writers/Docx.hs @@ -83,10 +83,10 @@ tests = [ testGroup "inlines" , testCompare "i18n blocks (headers and blockquotes)" "docx/i18n_blocks.native" - -- some level problems, look into that - -- , testCompare - -- "lists" - -- "docx/lists.native" + -- Continuation does not survive round-trip + , testCompare + "lists" + "docx/lists_writer.native" , testCompare "definition lists" "docx/definition_list.native" diff --git a/tests/docx/lists_writer.native b/tests/docx/lists_writer.native new file mode 100644 index 000000000..4c44ea603 --- /dev/null +++ b/tests/docx/lists_writer.native @@ -0,0 +1,17 @@ +[Header 2 ("some-nested-lists",[],[]) [Str "Some",Space,Str "nested",Space,Str "lists"] +,OrderedList (1,Decimal,Period) + [[Para [Str "one"]] + ,[Para [Str "two"] + ,OrderedList (1,LowerAlpha,DefaultDelim) + [[Para [Str "a"]] + ,[Para [Str "b"]]]]] +,BulletList + [[Para [Str "one"]] + ,[Para [Str "two"] + ,BulletList + [[Para [Str "three"] + ,BulletList + [[Para [Str "four"]]]]]] + ,[Para [Str "Same",Space,Str "list"]]] +,BulletList + [[Para [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]] -- cgit v1.2.3 From 59c4d28d8c70e3d23428897d78a3c401e30612e5 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 8 Mar 2015 04:42:50 +0300 Subject: Docx Writer: Tables test --- tests/Tests/Writers/Docx.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/Tests') diff --git a/tests/Tests/Writers/Docx.hs b/tests/Tests/Writers/Docx.hs index a22daadb8..80ce0014d 100644 --- a/tests/Tests/Writers/Docx.hs +++ b/tests/Tests/Writers/Docx.hs @@ -103,12 +103,12 @@ tests = [ testGroup "inlines" "hanging indents" "docx/hanging_indent.native" -- tables headers do not survive round-trip, should look into that - -- , testCompare - -- "tables" - -- "docx/tables.native" - -- , testCompare - -- "tables with lists in cells" - -- "docx/table_with_list_cell.native" + , testCompare + "tables" + "docx/tables.native" + , testCompare + "tables with lists in cells" + "docx/table_with_list_cell.native" , testCompare "code block" "docx/codeblock.native" -- cgit v1.2.3