1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
--
-- Tests for the system module
--
local image = require 'pandoc.image'
local tasty = require 'tasty'
local group = tasty.test_group
local test = tasty.test_case
local assert = tasty.assert
local svg_image = [==[<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
height="70" width="70"
viewBox="-35 -35 70 70">
<title>test</title>
<!-- document shape -->
<polygon points="-10,-31.53 -10,-3.25 0,0 10,-3.25 10,-23.53 2,-31.53" />
</svg>
]==]
return {
-- Check existence of static fields
group 'static fields' {
},
group 'size' {
test('returns a table', function ()
local imgsize = {
width = 70,
height = 70,
dpi_horz = 96,
dpi_vert = 96,
}
assert.are_same(image.size(svg_image), imgsize)
end),
test('fails on faulty eps', function ()
assert.error_matches(
function () image.size('%!PS EPSF') end,
'could not determine EPS size'
)
end),
test('fails if input is not an image', function ()
assert.error_matches(
function () image.size('not an image') end,
'could not determine image type'
)
end),
test('respects the dpi setting', function ()
local imgsize = {
width = 70,
height = 70,
dpi_horz = 300,
dpi_vert = 300,
}
assert.are_same(image.size(svg_image, {dpi=300}), imgsize)
end),
},
group 'format' {
test('SVG', function ()
assert.are_equal(image.format(svg_image), 'svg')
end),
test('returns nil if input is not an image', function ()
assert.is_nil(image.format('not an image'))
end),
},
}
|