mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-08 00:40:25 +00:00
potentially first version of SmartKeyRWLocker
This commit is contained in:
@@ -6,7 +6,10 @@ import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFails
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class SmartRWLockerTests {
|
||||
@Test
|
||||
@@ -148,4 +151,17 @@ class SmartRWLockerTests {
|
||||
assertEquals(false, locker.writeMutex.isLocked)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun exceptionOnLockingWillNotLockLocker() = runTest {
|
||||
val locker = SmartRWLocker()
|
||||
|
||||
locker.acquireRead()
|
||||
assertFails {
|
||||
realWithTimeout(1.seconds) {
|
||||
locker.lockWrite()
|
||||
}
|
||||
}
|
||||
assertFalse { locker.writeMutex.isLocked }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user