diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-30 23:52:36 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-30 23:52:36 -0700 |
commit | 143d5b732885a5186dd976ce1b74a91bcb417ead (patch) | |
tree | 461759648d4edfe939522facb80252c4e4b332e2 /tests | |
parent | f1885ae799fd29f243b0d51d63bf6bb3a1b0f035 (diff) | |
parent | 4d1d8a4b6ff6ca957c63233e344f2de4cd9e87bb (diff) | |
download | pandoc-143d5b732885a5186dd976ce1b74a91bcb417ead.tar.gz |
Merge pull request #1470 from jkr/metadata-test
Media test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Tests/Readers/Docx.hs | 26 | ||||
-rw-r--r-- | tests/docx.image1.jpeg | bin | 0 -> 46626 bytes |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/Tests/Readers/Docx.hs b/tests/Tests/Readers/Docx.hs index e8dd6b72e..494669fd5 100644 --- a/tests/Tests/Readers/Docx.hs +++ b/tests/Tests/Readers/Docx.hs @@ -5,7 +5,10 @@ import Text.Pandoc.Readers.Native import Text.Pandoc.Definition import Tests.Helpers import Test.Framework +import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as B +import qualified Data.ByteString.Char8 as B8 +import qualified Data.ByteString.Base64 as B64 import Text.Pandoc.Readers.Docx import Text.Pandoc.Writers.Native (writeNative) import qualified Data.Map as M @@ -52,6 +55,22 @@ testCompareWithOpts opts name docxFile nativeFile = testCompare :: String -> FilePath -> FilePath -> Test testCompare = testCompareWithOpts def +testCompareMediaIO :: String -> FilePath -> FilePath -> FilePath -> IO Test +testCompareMediaIO name docxFile mediaPath mediaFile = do + df <- B.readFile docxFile + mf <- B.readFile mediaFile + let (_, mb) = readDocx def df + dBytes = case M.lookup mediaPath mb of + Just bs -> bs + Nothing -> error "Media file not found" + d64 = B8.unpack $ B64.encode $ BS.concat $ B.toChunks dBytes + m64 = B8.unpack $ B64.encode $ BS.concat $ B.toChunks mf + return $ test id name (d64, m64) + +testCompareMedia :: String -> FilePath -> FilePath -> FilePath -> Test +testCompareMedia name docxFile mediaPath mediaFile = + buildTest $ testCompareMediaIO name docxFile mediaPath mediaFile + tests :: [Test] tests = [ testGroup "inlines" @@ -165,6 +184,13 @@ tests = [ testGroup "inlines" "docx.track_changes_deletion.docx" "docx.track_changes_deletion_all.native" ] + , testGroup "media" + [ testCompareMedia + "image extraction" + "docx.image.docx" + "media/image1.jpeg" + "docx.image1.jpeg" + ] , testGroup "metadata" [ testCompareWithOpts def{readerStandalone=True} "metadata fields" diff --git a/tests/docx.image1.jpeg b/tests/docx.image1.jpeg Binary files differnew file mode 100644 index 000000000..423dff48b --- /dev/null +++ b/tests/docx.image1.jpeg |