mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-29 03:00:31 +00:00
disable hard test of binary trees for js
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
actual val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
get() = true
|
||||||
@@ -11,6 +11,8 @@ import kotlin.test.assertTrue
|
|||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
import kotlin.time.measureTime
|
import kotlin.time.measureTime
|
||||||
|
|
||||||
|
expect val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
|
||||||
class SortedBinaryTreeNodeTests {
|
class SortedBinaryTreeNodeTests {
|
||||||
@Test
|
@Test
|
||||||
fun insertOnZeroLevelWorks() = runTest {
|
fun insertOnZeroLevelWorks() = runTest {
|
||||||
@@ -44,7 +46,8 @@ class SortedBinaryTreeNodeTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
fun deepInsertOnWorks() = runTest(timeout = 440.seconds) { // 440 due to js targets -.-
|
fun deepReInsertOnWorks() = runTest(timeout = 240.seconds) {
|
||||||
|
if (AllowDeepReInsertOnWorksTest == false) return@runTest
|
||||||
val zeroNode = SortedBinaryTreeNode(0)
|
val zeroNode = SortedBinaryTreeNode(0)
|
||||||
val rangeRadius = 500
|
val rangeRadius = 500
|
||||||
val nodes = mutableMapOf<Int, SortedBinaryTreeNode<Int>>()
|
val nodes = mutableMapOf<Int, SortedBinaryTreeNode<Int>>()
|
||||||
@@ -121,6 +124,41 @@ class SortedBinaryTreeNodeTests {
|
|||||||
assertTrue(sourceTreeSize == zeroNode.size())
|
assertTrue(sourceTreeSize == zeroNode.size())
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
fun deepInsertOnWorks() = runTest(timeout = 440.seconds) { // 440 due to js targets -.-
|
||||||
|
val zeroNode = SortedBinaryTreeNode(0)
|
||||||
|
val rangeRadius = 500
|
||||||
|
val nodes = mutableMapOf<Int, SortedBinaryTreeNode<Int>>()
|
||||||
|
for (i in -rangeRadius .. rangeRadius) {
|
||||||
|
nodes[i] = zeroNode.addSubNode(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i in -rangeRadius .. rangeRadius) {
|
||||||
|
val expectedNode = nodes.getValue(i)
|
||||||
|
val foundNode = zeroNode.findNode(i)
|
||||||
|
|
||||||
|
assertTrue(expectedNode === foundNode)
|
||||||
|
|
||||||
|
if (expectedNode === zeroNode) continue
|
||||||
|
|
||||||
|
val parentNode = zeroNode.findParentNode(i)
|
||||||
|
assertTrue(
|
||||||
|
parentNode ?.getLeftNode() === expectedNode || parentNode ?.getRightNode() === expectedNode,
|
||||||
|
"It is expected, that parent node with data ${parentNode ?.data} will be parent of ${expectedNode.data}, but its left subnode is ${parentNode ?.getLeftNode() ?.data} and right one is ${parentNode ?.getRightNode() ?.data}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val sourceTreeSize = zeroNode.size()
|
||||||
|
|
||||||
|
var previousData = -rangeRadius - 1
|
||||||
|
for (node in zeroNode) {
|
||||||
|
assertTrue(nodes[node.data] === node)
|
||||||
|
assertTrue(previousData == node.data - 1)
|
||||||
|
previousData = node.data
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(sourceTreeSize == zeroNode.size())
|
||||||
|
}
|
||||||
|
@Test
|
||||||
fun deepInsertIteratorWorking() = runTest {
|
fun deepInsertIteratorWorking() = runTest {
|
||||||
val zeroNode = SortedBinaryTreeNode(0)
|
val zeroNode = SortedBinaryTreeNode(0)
|
||||||
val rangeRadius = 500
|
val rangeRadius = 500
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
actual val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
get() = false
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
actual val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
get() = true
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
actual val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
get() = true
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
actual val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
get() = true
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
actual val AllowDeepReInsertOnWorksTest: Boolean
|
||||||
|
get() = true
|
||||||
@@ -15,14 +15,14 @@ kotlin {
|
|||||||
browser {
|
browser {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodejs {
|
nodejs {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ kotlin {
|
|||||||
browser {
|
browser {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodejs {
|
nodejs {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ kotlin {
|
|||||||
browser {
|
browser {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodejs {
|
nodejs {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ kotlin {
|
|||||||
browser {
|
browser {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodejs {
|
nodejs {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha {
|
||||||
timeout = "600000"
|
timeout = "240000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user