diff options
Diffstat (limited to 'src/test/kotlin/org/pacien')
-rw-r--r-- | src/test/kotlin/org/pacien/pandoc/filter/plantuml/FilterTest.kt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/kotlin/org/pacien/pandoc/filter/plantuml/FilterTest.kt b/src/test/kotlin/org/pacien/pandoc/filter/plantuml/FilterTest.kt new file mode 100644 index 0000000..4ec183b --- /dev/null +++ b/src/test/kotlin/org/pacien/pandoc/filter/plantuml/FilterTest.kt | |||
@@ -0,0 +1,39 @@ | |||
1 | package org.pacien.pandoc.filter.plantuml | ||
2 | |||
3 | import org.junit.Assert | ||
4 | import org.junit.Test | ||
5 | |||
6 | import java.io.* | ||
7 | import java.nio.file.Files | ||
8 | import java.nio.file.Paths | ||
9 | |||
10 | class FilterTest { | ||
11 | private fun testCompare(inputResource: String, expectedOutputResource: String) { | ||
12 | val inputStream = javaClass.getResourceAsStream(inputResource) | ||
13 | val expectedOutputFilePath = Paths.get(javaClass.getResource(expectedOutputResource).toURI()) | ||
14 | val expectedOutput = Files.readAllBytes(expectedOutputFilePath) | ||
15 | |||
16 | ByteArrayOutputStream().use { outputStream -> | ||
17 | Filter.filter(inputStream, outputStream) | ||
18 | Assert.assertArrayEquals(outputStream.toByteArray(), expectedOutput) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | /** | ||
23 | * Should only replace the PlantUML code block and leave other ones untouched. | ||
24 | */ | ||
25 | @Test fun testIdentifyBlock() = | ||
26 | testCompare("/identifyblock.input.json", "/identifyblock.expected.json") | ||
27 | |||
28 | /** | ||
29 | * Figure should be centered with a caption and a label. | ||
30 | */ | ||
31 | @Test fun testAttributes() = | ||
32 | testCompare("/attributes.input.json", "/attributes.expected.json") | ||
33 | |||
34 | /** | ||
35 | * Large figure should be scaled down to column width, keeping its aspect ratio. | ||
36 | */ | ||
37 | @Test fun testResize() = | ||
38 | testCompare("/resize.input.json", "/resize.expected.json") | ||
39 | } | ||