From 69bc6c2ae35883286d9c2b8cc77d5fa0a8c37351 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 26 Jul 2018 11:34:06 +0200 Subject: Kotlin rewrite, adding diagram options --- .../pacien/pandoc/filter/plantuml/FilterTest.kt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/kotlin/org/pacien/pandoc/filter/plantuml/FilterTest.kt (limited to 'src/test/kotlin/org/pacien/pandoc/filter/plantuml/FilterTest.kt') 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 @@ +package org.pacien.pandoc.filter.plantuml + +import org.junit.Assert +import org.junit.Test + +import java.io.* +import java.nio.file.Files +import java.nio.file.Paths + +class FilterTest { + private fun testCompare(inputResource: String, expectedOutputResource: String) { + val inputStream = javaClass.getResourceAsStream(inputResource) + val expectedOutputFilePath = Paths.get(javaClass.getResource(expectedOutputResource).toURI()) + val expectedOutput = Files.readAllBytes(expectedOutputFilePath) + + ByteArrayOutputStream().use { outputStream -> + Filter.filter(inputStream, outputStream) + Assert.assertArrayEquals(outputStream.toByteArray(), expectedOutput) + } + } + + /** + * Should only replace the PlantUML code block and leave other ones untouched. + */ + @Test fun testIdentifyBlock() = + testCompare("/identifyblock.input.json", "/identifyblock.expected.json") + + /** + * Figure should be centered with a caption and a label. + */ + @Test fun testAttributes() = + testCompare("/attributes.input.json", "/attributes.expected.json") + + /** + * Large figure should be scaled down to column width, keeping its aspect ratio. + */ + @Test fun testResize() = + testCompare("/resize.input.json", "/resize.expected.json") +} -- cgit v1.2.3