aboutsummaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-13 09:59:39 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-17 11:52:28 +0200
commitf6ac2b0f0a0183171aa2f6806ec67d8d21692a36 (patch)
treea912d7ba4d7d368b9a3683a6cf290ca135ee231a /core/src/test
parent86fcfb73d2d5124ae7748a80db29bdbb68607be4 (diff)
downloaddokka-f6ac2b0f0a0183171aa2f6806ec67d8d21692a36.tar.gz
dokka-f6ac2b0f0a0183171aa2f6806ec67d8d21692a36.tar.bz2
dokka-f6ac2b0f0a0183171aa2f6806ec67d8d21692a36.zip
Implement `ContentSourceSet`
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/kotlin/model/CompositeSourceSetIDTest.kt58
-rw-r--r--core/src/test/kotlin/model/ContentSourceSetTest.kt61
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"
+ )
+ }
+}