diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-17 10:46:26 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-17 11:52:28 +0200 |
commit | a2be91ea289ddb1a8634c5fd252243f1b9ab7000 (patch) | |
tree | 682463697296d7084d70ceb2816e65badf668fd0 /core/src/test/kotlin | |
parent | b439f0f4da19273a1b60df45aa380ecf2511de73 (diff) | |
download | dokka-a2be91ea289ddb1a8634c5fd252243f1b9ab7000.tar.gz dokka-a2be91ea289ddb1a8634c5fd252243f1b9ab7000.tar.bz2 dokka-a2be91ea289ddb1a8634c5fd252243f1b9ab7000.zip |
Implement SelfRepresentingSingletonSet and let `ContentSourceSet` conform to it
Diffstat (limited to 'core/src/test/kotlin')
-rw-r--r-- | core/src/test/kotlin/model/ContentSourceSetTest.kt | 6 | ||||
-rw-r--r-- | core/src/test/kotlin/utilities/SelfRepresentingSingletonSetTest.kt | 60 |
2 files changed, 63 insertions, 3 deletions
diff --git a/core/src/test/kotlin/model/ContentSourceSetTest.kt b/core/src/test/kotlin/model/ContentSourceSetTest.kt index b96180a2..74f7854b 100644 --- a/core/src/test/kotlin/model/ContentSourceSetTest.kt +++ b/core/src/test/kotlin/model/ContentSourceSetTest.kt @@ -19,17 +19,17 @@ class ContentSourceSetTest { ) assertFalse( - DokkaSourceSetID("m3", "s3") in contentSourceSet, + DokkaSourceSetID("m3", "s3") in contentSourceSet.sourceSetIDs, "Expected source set id not being contained in content source set" ) assertTrue( - DokkaSourceSetID("m1", "s1") in contentSourceSet, + DokkaSourceSetID("m1", "s1") in contentSourceSet.sourceSetIDs, "Expected source set id being contained in content source set" ) assertTrue( - DokkaSourceSetID("m1+m2", "s1+s2") in contentSourceSet, + DokkaSourceSetID("m1+m2", "s1+s2") in contentSourceSet.sourceSetIDs, "Expected merged source set being contained in content source set" ) } diff --git a/core/src/test/kotlin/utilities/SelfRepresentingSingletonSetTest.kt b/core/src/test/kotlin/utilities/SelfRepresentingSingletonSetTest.kt new file mode 100644 index 00000000..bef43565 --- /dev/null +++ b/core/src/test/kotlin/utilities/SelfRepresentingSingletonSetTest.kt @@ -0,0 +1,60 @@ +package utilities + +import org.jetbrains.dokka.utilities.SelfRepresentingSingletonSet +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class SelfRepresentingSingletonSetTest { + + data class TestModel(val index: Int = 0) : SelfRepresentingSingletonSet<TestModel> + + @Test + fun size() { + assertEquals(1, TestModel().size) + } + + @Test + fun contains() { + val m0 = TestModel(0) + val m1 = TestModel(1) + + assertFalse(m1 in m0) + assertFalse(m0 in m1) + assertTrue(m0 in m0) + assertTrue(m1 in m1) + assertTrue(TestModel(0) in m0) + } + + @Test + fun `containsAll is compliant to setOf`() { + val setOf = setOf(TestModel()) + val testModel = TestModel() + + assertEquals( + setOf.containsAll(emptyList()), testModel.containsAll(emptyList()) + ) + + assertEquals( + setOf.containsAll(listOf(TestModel())), testModel.containsAll(listOf(TestModel())) + ) + + assertEquals( + setOf.containsAll(listOf(TestModel(0), TestModel(1))), + testModel.containsAll(listOf(TestModel(0), TestModel(1))) + ) + } + + @Test + fun isEmpty() { + assertFalse(TestModel().isEmpty()) + } + + @Test + fun iterator() { + assertEquals( + listOf(TestModel()), TestModel(0).iterator().asSequence().toList() + ) + } +} |