From 86d6d567a40bba1cf811089afeb35a4ca6c9a122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Segovia=20C=C3=B3rdoba?= Date: Tue, 3 Dec 2024 17:15:31 +0100 Subject: [PATCH] Add more `TreeNode` tests --- .../kotlin/com/javiersc/kotlin/stdlib/TreeNodeTest.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kotlin-stdlib/common/test/kotlin/com/javiersc/kotlin/stdlib/TreeNodeTest.kt b/kotlin-stdlib/common/test/kotlin/com/javiersc/kotlin/stdlib/TreeNodeTest.kt index b94b50ca..00d8510b 100644 --- a/kotlin-stdlib/common/test/kotlin/com/javiersc/kotlin/stdlib/TreeNodeTest.kt +++ b/kotlin-stdlib/common/test/kotlin/com/javiersc/kotlin/stdlib/TreeNodeTest.kt @@ -1,13 +1,16 @@ package com.javiersc.kotlin.stdlib import com.javiersc.kotlin.stdlib.tree.TreeNode +import com.javiersc.kotlin.stdlib.tree.TreeNodeException import com.javiersc.kotlin.stdlib.tree.TreeNodeIterators import com.javiersc.kotlin.stdlib.tree.tree import kotlin.test.DefaultAsserter.assertEquals import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertNull +import kotlin.test.assertTrue internal class TreeNodeTest { @@ -65,6 +68,14 @@ internal class TreeNodeTest { " └── Milk Shake\n", actual = root.prettyString(), ) + + assertTrue { root.isRoot } + assertEquals(5, root.nodeCount) + assertEquals(3, root.height) + assertEquals(0, root.depth) + assertEquals(3, normalTeaNode.depth) + assertEquals(listOf(teaNode, beveragesNode, root), root.path(teaNode)) + assertFailsWith { beveragesNode.path(root) } } @Test