FSFolder.isCyclic() tests
Test Workflow / Lint and test library (pull_request) Successful in 3m56s
Details
Test Workflow / Lint and test library (pull_request) Successful in 3m56s
Details
This commit is contained in:
parent
4fa2ad53b0
commit
e53d96a74b
|
@ -0,0 +1,42 @@
|
||||||
|
package filesystem
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import kotlin.test.assertFalse
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class FSEntryTest {
|
||||||
|
@Test
|
||||||
|
fun `non-cyclic folder`() {
|
||||||
|
val folder =
|
||||||
|
FSFolder(
|
||||||
|
"folder",
|
||||||
|
listOf(
|
||||||
|
FSFolder("folder", listOf()),
|
||||||
|
FSFile("text.txt", "Hello!"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assertFalse(folder.isCyclic())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `cyclic folder`() {
|
||||||
|
val files = mutableListOf<FSEntry>()
|
||||||
|
val folder = FSFolder("folder", files)
|
||||||
|
files.add(folder)
|
||||||
|
assertTrue(folder.isCyclic())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `long cyclic folder`() {
|
||||||
|
val files = mutableListOf<FSEntry>()
|
||||||
|
val folder1 = FSFolder("folder", files)
|
||||||
|
val folder2 = FSFolder("folder2", listOf(folder1))
|
||||||
|
val folder3 = FSFolder("folder3", listOf(folder2))
|
||||||
|
val folder4 = FSFolder("folder4", listOf(folder3))
|
||||||
|
files.add(folder4)
|
||||||
|
assertTrue(folder1.isCyclic())
|
||||||
|
assertTrue(folder2.isCyclic())
|
||||||
|
assertTrue(folder3.isCyclic())
|
||||||
|
assertTrue(folder4.isCyclic())
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue