1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package model
import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.model.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"
)
}
@Test
fun `plus operator`() {
val composite = DokkaSourceSetID("m1", "s1") + DokkaSourceSetID("m2", "s2") + DokkaSourceSetID("m3", "s3")
assertEquals(
DokkaSourceSetID("m1+m2+m3", "s1+s2+s3"), composite.merged,
"Expected all three source sets being merged in order"
)
}
operator fun DokkaSourceSetID.plus(other: DokkaSourceSetID): CompositeSourceSetID {
return CompositeSourceSetID(listOf(this, other))
}
}
|