From a2be91ea289ddb1a8634c5fd252243f1b9ab7000 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Mon, 17 Aug 2020 10:46:26 +0200 Subject: Implement SelfRepresentingSingletonSet and let `ContentSourceSet` conform to it --- .../utilities/SelfRepresentingSingletonSetTest.kt | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 core/src/test/kotlin/utilities/SelfRepresentingSingletonSetTest.kt (limited to 'core/src/test/kotlin/utilities/SelfRepresentingSingletonSetTest.kt') 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 + + @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() + ) + } +} -- cgit