mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-05-22 15:57:23 +00:00
Compare commits
3 Commits
0.24.8
...
feb52ecbd1
| Author | SHA1 | Date | |
|---|---|---|---|
| feb52ecbd1 | |||
| 706a787163 | |||
| f00cb81db1 |
@@ -1,2 +0,0 @@
|
|||||||
actual val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
get() = true
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
actual val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
get() = false
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
actual val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
get() = true
|
|
||||||
@@ -1,25 +1,20 @@
|
|||||||
package dev.inmo.micro_utils.coroutines
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
|
||||||
class HandleSafelyCoroutineContextTest {
|
class HandleSafelyCoroutineContextTest {
|
||||||
@Test
|
@Test
|
||||||
fun testHandleSafelyCoroutineContext() {
|
fun testHandleSafelyCoroutineContext() = runTest {
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
val scope = this
|
||||||
var contextHandlerHappen = false
|
var contextHandlerHappen = false
|
||||||
var localHandlerHappen = false
|
var localHandlerHappen = false
|
||||||
var defaultHandlerHappen = false
|
|
||||||
defaultSafelyExceptionHandler = {
|
|
||||||
defaultHandlerHappen = true
|
|
||||||
throw it
|
|
||||||
}
|
|
||||||
val contextHandler: ExceptionHandler<Unit> = {
|
|
||||||
contextHandlerHappen = true
|
|
||||||
}
|
|
||||||
val checkJob = scope.launch {
|
val checkJob = scope.launch {
|
||||||
safelyWithContextExceptionHandler(contextHandler) {
|
runCatchingLogging ({
|
||||||
safely(
|
contextHandlerHappen = true
|
||||||
|
}) {
|
||||||
|
runCatchingLogging (
|
||||||
{
|
{
|
||||||
localHandlerHappen = true
|
localHandlerHappen = true
|
||||||
}
|
}
|
||||||
@@ -29,10 +24,8 @@ class HandleSafelyCoroutineContextTest {
|
|||||||
println(coroutineContext)
|
println(coroutineContext)
|
||||||
error("That must happen too:)")
|
error("That must happen too:)")
|
||||||
}
|
}
|
||||||
}
|
}.join()
|
||||||
launchSynchronously { checkJob.join() }
|
|
||||||
assert(contextHandlerHappen)
|
assert(contextHandlerHappen)
|
||||||
assert(localHandlerHappen)
|
assert(localHandlerHappen)
|
||||||
assert(defaultHandlerHappen)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.collections.SortedBinaryTreeNode
|
import dev.inmo.micro_utils.coroutines.collections.SortedBinaryTreeNode
|
||||||
import dev.inmo.micro_utils.coroutines.collections.addSubNode
|
import dev.inmo.micro_utils.coroutines.collections.addSubNode
|
||||||
import dev.inmo.micro_utils.coroutines.collections.findNode
|
import dev.inmo.micro_utils.coroutines.collections.findNode
|
||||||
@@ -10,8 +12,6 @@ import kotlin.test.assertEquals
|
|||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
expect val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
|
|
||||||
class SortedBinaryTreeNodeTests {
|
class SortedBinaryTreeNodeTests {
|
||||||
@Test
|
@Test
|
||||||
fun insertOnZeroLevelWorks() = runTest {
|
fun insertOnZeroLevelWorks() = runTest {
|
||||||
@@ -46,7 +46,6 @@ class SortedBinaryTreeNodeTests {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
fun deepReInsertOnWorks() = runTest(timeout = 300.seconds) {
|
fun deepReInsertOnWorks() = runTest(timeout = 300.seconds) {
|
||||||
if (AllowDeepInsertOnWorksTest == 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>>()
|
||||||
@@ -124,7 +123,6 @@ class SortedBinaryTreeNodeTests {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
fun deepInsertOnWorks() = runTest(timeout = 240.seconds) {
|
fun deepInsertOnWorks() = runTest(timeout = 240.seconds) {
|
||||||
if (AllowDeepInsertOnWorksTest == 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>>()
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
actual val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
get() = true
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
actual val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
get() = true
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
actual val AllowDeepInsertOnWorksTest: Boolean
|
|
||||||
get() = true
|
|
||||||
Reference in New Issue
Block a user