Skip to content

Commit

Permalink
Test on other targets in addition to JVM and Android
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Dec 20, 2023
1 parent e195c8c commit db755bb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
24 changes: 24 additions & 0 deletions korge-core/test/korlibs/io/file/std/AppendBaseTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package korlibs.io.file.std

import korlibs.io.file.*
import korlibs.io.stream.*
import kotlin.test.*

class AppendBaseTest {
companion object {
suspend fun _testAppendVfs(file: VfsFile) {
file.delete()
try {
file.openUse(VfsOpenMode.APPEND) {
writeString("hello")
}
file.openUse(VfsOpenMode.APPEND) {
writeString(" world")
}
assertEquals("hello world", file.readString())
} finally {
file.delete()
}
}
}
}
12 changes: 12 additions & 0 deletions korge-core/test/korlibs/io/file/std/LocalVfsAppendTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package korlibs.io.file.std

import korlibs.io.async.*
import korlibs.platform.*
import kotlin.test.*

class LocalVfsAppendTest {
@Test
fun test() = suspendTest(cond = { localVfs(StandardPaths.temp).vfs is LocalVfs }) {
AppendBaseTest._testAppendVfs(localVfs(StandardPaths.temp)["file.append.${Platform.rawPlatformName}.txt"])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ class LocalVfsJvmAndroidTest {
}

suspend fun _testAppendVfs(vfs: Vfs, name: String) {
val file = vfs[StandardPaths.temp]["file.append.$name.txt"]
file.delete()
try {
file.openUse(VfsOpenMode.APPEND) {
writeString("hello")
}
file.openUse(VfsOpenMode.APPEND) {
writeString(" world")
}
assertEquals("hello world", file.readString())
} finally {
file.delete()
}
AppendBaseTest._testAppendVfs(vfs[StandardPaths.temp]["file.append.$name.txt"])
}
}

0 comments on commit db755bb

Please sign in to comment.