All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.dev.mokkery.internal.matcher.capture.DefaultCapture.kt Maven / Gradle / Ivy

Go to download

Mokkery is a mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.

The newest version!
package dev.mokkery.internal.matcher.capture

import dev.mokkery.matcher.capture.ContainerCapture
import kotlinx.atomicfu.locks.reentrantLock
import kotlinx.atomicfu.locks.withLock

internal data class DefaultContainerCapture(
    val capturedValues: MutableList = mutableListOf()
): ContainerCapture {

    private val lock = reentrantLock()

    override val values: List get() = lock.withLock { capturedValues.toMutableList() }

    override fun capture(value: T) {
        lock.withLock { capturedValues.add(value) }
    }

    override fun toString(): String = "container(${capturedValues.joinToString()})"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy