diff options
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/kotlin/model/CompositeSourceSetIDTest.kt | 58 | ||||
-rw-r--r-- | core/src/test/kotlin/model/ContentSourceSetTest.kt | 61 |
2 files changed, 119 insertions, 0 deletions
diff --git a/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt new file mode 100644 index 00000000..68af259d --- /dev/null +++ b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt @@ -0,0 +1,58 @@ +package model + +import org.jetbrains.dokka.DokkaSourceSetID +import org.jetbrains.dokka.pages.CompositeSourceSetID +import kotlin.test.* + +class CompositeSourceSetIDTest { + + @Test + fun `constructor fails with empty collection`() { + assertFailsWith<IllegalArgumentException>("Expected no construction of empty `CompositeSourceSetID`") { + CompositeSourceSetID(emptyList()) + } + } + + @Test + fun `merged for single source set`() { + val sourceSetID = DokkaSourceSetID("module", "sourceSet") + val composite = CompositeSourceSetID(sourceSetID) + + assertEquals( + composite.merged, sourceSetID, + "Expected merged source set id to be equal to single child" + ) + } + + @Test + fun `merged with multiple source sets`() { + val composite = CompositeSourceSetID( + listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"), DokkaSourceSetID("m3", "s3")) + ) + + assertEquals( + DokkaSourceSetID("m1+m2+m3", "s1+s2+s3"), composite.merged, + "Expected merged source set id to concatenate source sets" + ) + } + + @Test + fun `contains with child sourceSetID`() { + val composite = CompositeSourceSetID(listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"))) + + assertFalse( + DokkaSourceSetID("m3", "s3") in composite, + "Expected source set id not being contained in composite" + ) + + assertTrue( + DokkaSourceSetID("m1", "s1") in composite, + "Expected child source set id being contained in composite" + ) + + assertTrue( + DokkaSourceSetID("m1+m2", "s1+s2") in composite, + "Expected merged source set id being contained in composite" + ) + } +} diff --git a/core/src/test/kotlin/model/ContentSourceSetTest.kt b/core/src/test/kotlin/model/ContentSourceSetTest.kt new file mode 100644 index 00000000..cb17bcba --- /dev/null +++ b/core/src/test/kotlin/model/ContentSourceSetTest.kt @@ -0,0 +1,61 @@ +package model + +import org.jetbrains.dokka.DokkaSourceSetID +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.pages.CompositeSourceSetID +import org.jetbrains.dokka.pages.ContentSourceSet +import org.jetbrains.dokka.pages.sourceSetIDs +import kotlin.test.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class ContentSourceSetTest { + @Test + fun `contains sourceSetId`() { + val contentSourceSet = ContentSourceSet( + sourceSetIDs = CompositeSourceSetID(listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"))), + displayName = "displayName", + analysisPlatform = Platform.common + ) + + assertFalse( + DokkaSourceSetID("m3", "s3") in contentSourceSet, + "Expected source set id not being contained in content source set" + ) + + assertTrue( + DokkaSourceSetID("m1", "s1") in contentSourceSet, + "Expected source set id being contained in content source set" + ) + + assertTrue( + DokkaSourceSetID("m1+m2", "s1+s2") in contentSourceSet, + "Expected merged source set being contained in content source set" + ) + } + + @Test + fun `Iterable contains sourceSetId`() { + + val contentSourceSet = ContentSourceSet( + sourceSetIDs = CompositeSourceSetID(listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"))), + displayName = "displayName", + analysisPlatform = Platform.common + ) + + assertFalse( + DokkaSourceSetID("m3", "s3") in listOf(contentSourceSet).sourceSetIDs, + "Expected source set id not being contained in content source set" + ) + + assertTrue( + DokkaSourceSetID("m1", "s1") in listOf(contentSourceSet).sourceSetIDs, + "Expected source set id being contained in content source set" + ) + + assertTrue( + DokkaSourceSetID("m1+m2", "s1+s2") in listOf(contentSourceSet).sourceSetIDs, + "Expected merged source set being contained in content source set" + ) + } +} |