diff options
author | Ryan Nett <JNett96@gmail.com> | 2021-05-06 02:09:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-06 11:09:21 +0200 |
commit | 326048cd6ed3334a84e489dac8c692bc184709c0 (patch) | |
tree | fe9004e41ba7731bb90d4cbdf022e611d5c269e1 /plugins/base/src/test | |
parent | 63378589a37b740cad0ede77b159e888fbbed89c (diff) | |
download | dokka-326048cd6ed3334a84e489dac8c692bc184709c0.tar.gz dokka-326048cd6ed3334a84e489dac8c692bc184709c0.tar.bz2 dokka-326048cd6ed3334a84e489dac8c692bc184709c0.zip |
Fix line separator issues (#1887)
* Fix line separator issues
* Test fix
* Handle just CR as well, add better test
* Add escaped \r\n to tests
Diffstat (limited to 'plugins/base/src/test')
2 files changed, 27 insertions, 14 deletions
diff --git a/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt b/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt index a2c2f97d..4560c532 100644 --- a/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt +++ b/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt @@ -1,8 +1,12 @@ package parsers -import org.jetbrains.dokka.base.parsers.moduleAndPackage.* +import org.jetbrains.dokka.base.parsers.moduleAndPackage.IllegalModuleAndPackageDocumentation import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.Module import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.Package +import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationFile +import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationFragment +import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationSource +import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentationFragments import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test @@ -12,9 +16,7 @@ import java.nio.file.Path class ParseModuleAndPackageDocumentationFragmentsTest { - @Test - fun `basic example`() { - + private fun testBasicExample(lineSeperator: String = "\n") { val source = source( """ # Module kotlin-demo @@ -23,11 +25,11 @@ class ParseModuleAndPackageDocumentationFragmentsTest { # Package org.jetbrains.kotlin.demo Package demo description ## Level 2 heading - Heading 2 + Heading 2\r\n # Package org.jetbrains.kotlin.demo2 Package demo2 description - """.trimIndent() + """.trimIndent().replace("\n", lineSeperator) ) val fragments = parseModuleAndPackageDocumentationFragments(source) @@ -42,7 +44,7 @@ class ParseModuleAndPackageDocumentationFragmentsTest { ModuleAndPackageDocumentationFragment( classifier = Package, name = "org.jetbrains.kotlin.demo", - documentation = "Package demo description\n## Level 2 heading\nHeading 2", + documentation = "Package demo description${lineSeperator}## Level 2 heading${lineSeperator}Heading 2\\r\\n", source = source ), ModuleAndPackageDocumentationFragment( @@ -57,6 +59,16 @@ class ParseModuleAndPackageDocumentationFragmentsTest { } @Test + fun `basic example`() { + testBasicExample() + } + + @Test + fun `CRLF line seperators`() { + testBasicExample("\r\n") + } + + @Test fun `no module name specified fails`() { val exception = assertThrows<IllegalModuleAndPackageDocumentation> { parseModuleAndPackageDocumentationFragments( diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt index a3069107..4b4116a2 100644 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt +++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt @@ -14,7 +14,6 @@ import org.junit.jupiter.api.assertThrows import testApi.testRunner.TestDokkaConfigurationBuilder import testApi.testRunner.dModule import testApi.testRunner.dPackage -import java.lang.IllegalStateException class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAndPackageDocumentationReaderTest() { @@ -30,11 +29,11 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd This is moduleA # Package sample.a - This is package sample.a + This is package sample.a\r\n # Package noise.b This will just add some noise - """.trimIndent() + """.trimIndent().replace("\n", "\r\n") ) includeSourceSetB.writeText( @@ -114,9 +113,11 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd fun `assert moduleA with unknown source set`() { assertThrows<IllegalStateException>( "Expected no documentation received for module with unknown sourceSet" - ) { reader[ - dModule("moduleA", sourceSets = setOf(configurationBuilder.unattachedSourceSet { name = "unknown" })) - ]} + ) { + reader[ + dModule("moduleA", sourceSets = setOf(configurationBuilder.unattachedSourceSet { name = "unknown" })) + ] + } } @Test @@ -140,7 +141,7 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd val documentation = reader[dPackage(DRI("sample.a"), sourceSets = setOf(sourceSetA))] assertEquals(1, documentation.keys.size, "Expected only one entry from sourceSetA") assertEquals(sourceSetA, documentation.keys.single(), "Expected only one entry from sourceSetA") - assertEquals("This is package sample.a", documentation.texts.single()) + assertEquals("This is package sample.a\\r\\n", documentation.texts.single()) } @Test |