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

commonTest.okio.UseTest.kt Maven / Gradle / Ivy

There is a newer version: 2.0.1.0-RC1
Show newest version
package okio

import kotlin.test.Test
import okio.Path.Companion.toPath
import okio.fakefilesystem.FakeFileSystem

class UseTest {
  val fakeFileSystem = FakeFileSystem(clock = FakeClock()).also { it.emulateUnix() }

  val base = "/cache".toPath().also {
    fakeFileSystem.createDirectories(it)
  }

  @Test
  fun closesWithUseBlock() {
    fun testMethodWithUse() {
      val sink = fakeFileSystem.sink(base / "all-files-includes-file")

      sink.use {
        return@testMethodWithUse
      }
    }

    testMethodWithUse()

    fakeFileSystem.checkNoOpenFiles()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy