git.iko.soy/typeable/pandoc
on master help sign in
Add DocX automated tests.

Note this makes use of input and output files in the tests/ dir.

commitf928e4c8dce694c47e0cda35f82bfadd55c0e4b2 authorJesse Rosenthal <jrosenthal@jhu.edu> dateSun 15 Jun 2014, 14:55 (12 years ago) parent3bc818d
19 files changed+139
tests/Tests/Readers/DocX.hs+68 tests/docx.block_quotes.docx tests/docx.block_quotes_parse_indent.native+8 tests/docx.headers.docx tests/docx.headers.native+5 tests/docx.image.docx tests/docx.image_no_embed.native+2 tests/docx.inline_formatting.docx tests/docx.inline_formatting.native+5 tests/docx.links.docx tests/docx.links.native+6 tests/docx.lists.docx tests/docx.lists.native+18 tests/docx.notes.docx tests/docx.notes.native+2 tests/docx.tables.docx tests/docx.tables.native+24 tests/docx.unicode.docx tests/docx.unicode.native+1
tests/Tests/Readers/DocX.hsnew file+68
@@ -0,0 +1,68 @@
1+module Tests.Readers.DocX (tests) where
2+
3+import Text.Pandoc.Options
4+import Text.Pandoc.Readers.Native
5+import Text.Pandoc.Definition
6+import Tests.Helpers
7+import Test.Framework
8+import qualified Data.ByteString.Lazy as B
9+import Text.Pandoc.Readers.DocX
10+
11+compareOutput :: FilePath -> FilePath -> IO (Pandoc, Pandoc)
12+compareOutput docxFile nativeFile = do
13+ df <- B.readFile docxFile
14+ nf <- Prelude.readFile nativeFile
15+ return $ (readDocX def df, readNative nf)
16+
17+testCompare' :: String -> FilePath -> FilePath -> IO Test
18+testCompare' name docxFile nativeFile = do
19+ (dp, np) <- compareOutput docxFile nativeFile
20+ return $ test id name (dp, np)
21+
22+testCompare :: String -> FilePath -> FilePath -> Test
23+testCompare name docxFile nativeFile =
24+ buildTest $ testCompare' name docxFile nativeFile
25+
26+
27+tests :: [Test]
28+tests = [ testGroup "inlines"
29+ [ testCompare
30+ "font formatting"
31+ "docx.inline_formatting.docx"
32+ "docx.inline_formatting.native"
33+ , testCompare
34+ "hyperlinks"
35+ "docx.links.docx"
36+ "docx.links.native"
37+ , testCompare
38+ "inline image with reference output"
39+ "docx.image.docx"
40+ "docx.image_no_embed.native"
41+ , testCompare
42+ "handling unicode input"
43+ "docx.unicode.docx"
44+ "docx.unicode.native"]
45+ , testGroup "blocks"
46+ [ testCompare
47+ "headers"
48+ "docx.headers.docx"
49+ "docx.headers.native"
50+ , testCompare
51+ "lists"
52+ "docx.lists.docx"
53+ "docx.lists.native"
54+ , testCompare
55+ "footnotes and endnotes"
56+ "docx.notes.docx"
57+ "docx.notes.native"
58+ , testCompare
59+ "blockquotes (parsing indent as blockquote)"
60+ "docx.block_quotes.docx"
61+ "docx.block_quotes_parse_indent.native"
62+ , testCompare
63+ "tables"
64+ "docx.tables.docx"
65+ "docx.tables.native"
66+ ]
67+ ]
68+
tests/docx.block_quotes.docxnew file

Binary file not shown.

tests/docx.block_quotes_parse_indent.nativenew file+8
@@ -0,0 +1,8 @@
1+[Header 2 ("",[],[]) [Str "Some",Space,Str "block",Space,Str "quotes,",Space,Str "in",Space,Str "different",Space,Str "ways"]
2+,Para [Str "This",Space,Str "is",Space,Str "the",Space,Str "proper",Space,Str "way,",Space,Str "with",Space,Str "a",Space,Str "style"]
3+,BlockQuote
4+ [Para [Str "I",Space,Str "don\8217t",Space,Str "know",Space,Str "why",Space,Str "this",Space,Str "would",Space,Str "be",Space,Str "in",Space,Str "italics,",Space,Str "but",Space,Str "so",Space,Str "it",Space,Str "appears",Space,Str "to",Space,Str "be",Space,Str "on",Space,Str "my",Space,Str "screen."]]
5+,Para [Str "And",Space,Str "this",Space,Str "is",Space,Str "the",Space,Str "way",Space,Str "that",Space,Str "most",Space,Str "people",Space,Str "do",Space,Str "it:"]
6+,BlockQuote
7+ [Para [Str "I",Space,Str "just",Space,Str "indented",Space,Str "this,",Space,Str "so",Space,Str "it",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "I",Space,Str "think",Space,Str "this",Space,Str "is",Space,Str "how",Space,Str "most",Space,Str "people",Space,Str "do",Space,Str "block",Space,Str "quotes",Space,Str "in",Space,Str "their",Space,Str "documents."]]
8+,Para [Str "And",Space,Str "back",Space,Str "to",Space,Str "the",Space,Str "normal",Space,Str "style."]]
tests/docx.headers.docxnew file

Binary file not shown.

tests/docx.headers.nativenew file+5
@@ -0,0 +1,5 @@
1+[Header 1 ("",[],[]) [Str "A",Space,Str "Test",Space,Str "of",Space,Str "Headers"]
2+,Header 2 ("",[],[]) [Str "Second",Space,Str "Level"]
3+,Para [Str "Some",Space,Str "plain",Space,Str "text."]
4+,Header 3 ("",[],[]) [Str "Third",Space,Str "level"]
5+,Para [Str "Some",Space,Str "more",Space,Str "plain",Space,Str "text."]]
tests/docx.image.docxnew file

Binary file not shown.

tests/docx.image_no_embed.nativenew file+2
@@ -0,0 +1,2 @@
1+[Header 2 ("",[],[]) [Str "An",Space,Str "image"]
2+,Para [Image [] ("word/media/image1.jpeg","")]]
tests/docx.inline_formatting.docxnew file

Binary file not shown.

tests/docx.inline_formatting.nativenew file+5
@@ -0,0 +1,5 @@
1+[Para [Str "Regular",Space,Str "text",Space,Emph [Str "italics"],Space,Strong [Str "bold",Space,Emph [Str "bold",Space,Str "italics"]],Str "."]
2+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "Small",Space,Str "Caps"],Str ",",Space,Str "and",Space,Str "this",Space,Str "is",Space,Strikeout [Str "strikethrough"],Str "."]
3+,Para [Str "Some",Space,Str "people",Space,Str "use",Space,Span ("",[],[("underline","single")]) [Str "single",Space,Str "underlines",Space,Str "for",Space,Emph [Str "emphasis"]],Str "."]
4+,Para [Str "Above",Space,Str "the",Space,Str "line",Space,Str "is",Space,Superscript [Str "superscript"],Space,Str "and",Space,Str "below",Space,Str "the",Space,Str "line",Space,Str "is",Space,Subscript [Str "subscript"],Str "."]
5+,Para [Str "A",Space,Str "line",LineBreak,Str "break."]]
tests/docx.links.docxnew file

Binary file not shown.

tests/docx.links.nativenew file+6
@@ -0,0 +1,6 @@
1+[Header 2 ("",[],[]) [Str "An",Space,Str "internal",Space,Str "link",Space,Str "and",Space,Str "an",Space,Str "external",Space,Str "link"]
2+,Para [Str "An",Space,Link [Str "external",Space,Str "link"] ("http://google.com",""),Space,Str "to",Space,Str "a",Space,Str "popular",Space,Str "website."]
3+,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#_A_section_for",""),Space,Str "to",Space,Str "a",Space,Str "section",Space,Str "header."]
4+,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#my_bookmark",""),Space,Str "to",Space,Str "a",Space,Str "bookmark."]
5+,Header 2 ("_A_section_for",[],[]) [Str "A",Space,Str "section",Space,Str "for",Space,Str "testing",Space,Str "link",Space,Str "targets"]
6+,Para [Str "A",Space,Str "bookmark",Space,Str "right",Space,Span ("my_bookmark",["anchor"],[]) [],Str "here"]]
tests/docx.lists.docxnew file

Binary file not shown.

tests/docx.lists.nativenew file+18
@@ -0,0 +1,18 @@
1+[Header 2 ("",[],[]) [Str "Some",Space,Str "nested",Space,Str "lists"]
2+,OrderedList (1,Decimal,Period)
3+ [[Para [Str "one"]]
4+ ,[Para [Str "two"]
5+ ,OrderedList (1,LowerAlpha,DefaultDelim)
6+ [[Para [Str "a"]]
7+ ,[Para [Str "b"]]]]]
8+,BulletList
9+ [[Para [Str "one"]]
10+ ,[Para [Str "two"]
11+ ,BulletList
12+ [[Para [Str "three"]
13+ ,BulletList
14+ [[Para [Str "four"]
15+ ,Para [Str "Sub",Space,Str "paragraph"]]]]]]
16+ ,[Para [Str "Same",Space,Str "list"]]]
17+,BulletList
18+ [[Para [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]]
tests/docx.notes.docxnew file

Binary file not shown.

tests/docx.notes.nativenew file+2
@@ -0,0 +1,2 @@
1+[Header 2 ("",[],[]) [Str "A",Space,Str "footnote"]
2+,Para [Str "Test",Space,Str "footnote.",Note [Para [Space,Str "My",Space,Str "note."]],Space,Str "Test",Space,Str "endnote.",Note [Para [Space,Str "This",Space,Str "is",Space,Str "an",Space,Str "endnote",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]]]]
tests/docx.tables.docxnew file

Binary file not shown.

tests/docx.tables.nativenew file+24
@@ -0,0 +1,24 @@
1+[Header 2 ("",[],[]) [Str "A",Space,Str "table,",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "a",Space,Str "header",Space,Str "row"]
2+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0]
3+ [[Para [Str "Name"]]
4+ ,[Para [Str "Game"]]
5+ ,[Para [Str "Fame"]]
6+ ,[Para [Str "Blame"]]]
7+ [[[Para [Str "Lebron",Space,Str "James"]]
8+ ,[Para [Str "Basketball"]]
9+ ,[Para [Str "Very",Space,Str "High"]]
10+ ,[Para [Str "Leaving",Space,Str "Cleveland"]]]
11+ ,[[Para [Str "Ryan",Space,Str "Braun"]]
12+ ,[Para [Str "Baseball"]]
13+ ,[Para [Str "Moderate"]]
14+ ,[Para [Str "Steroids"]]]
15+ ,[[Para [Str "Russell",Space,Str "Wilson"]]
16+ ,[Para [Str "Football"]]
17+ ,[Para [Str "High"]]
18+ ,[Para [Str "Tacky",Space,Str "uniform"]]]]
19+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
20+ []
21+ [[[Para [Str "Sinple"]]
22+ ,[Para [Str "Table"]]]
23+ ,[[Para [Str "Without"]]
24+ ,[Para [Str "Header"]]]]]
tests/docx.unicode.docxnew file

Binary file not shown.

tests/docx.unicode.nativenew file+1
@@ -0,0 +1 @@
1+[Para [Str "Hello,",Space,Str "\19990\30028.",Space,Str "This",Space,Str "costs",Space,Str "\8364\&10."]]