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

commonTest.io.github.vinccool96.ref.WeakReferenceTest.kt Maven / Gradle / Ivy

package io.github.vinccool96.ref

import kotlin.test.Test
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertSame

class WeakReferenceTest {

    @Test
    fun testValue() {
        val obj = Any()
        val ref = WeakReferenceFactory.createWeakRef(obj)
        assertSame(obj, ref.value)
    }

    @Test
    fun testGet() {
        val obj = Any()
        val ref = WeakReferenceFactory.createWeakRef(obj)
        assertSame(obj, ref.get())
    }

    @Test
    fun testClear() {
        val obj = Any()
        val ref = WeakReferenceFactory.createWeakRef(obj)
        assertNotNull(ref.get())
        ref.clear()
        assertNull(ref.get())
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy