Test IO operations with enveloop.
Failed reading file with `readAvaible` (testDataReading)
This commit is contained in:
parent
5ce8ab40d8
commit
72399e852a
@ -1,10 +1,12 @@
|
||||
package hep.dataforge.io
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import kotlinx.io.core.readAvailable
|
||||
import org.junit.Test
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class BinaryTest {
|
||||
val envelope = Envelope {
|
||||
@ -55,4 +57,26 @@ class BinaryTest {
|
||||
assertEquals(binary.size.toInt(), binary.toBytes().size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDataReading() {
|
||||
println(System.getProperty("user.dir"))
|
||||
val tmpPath = Files.createTempFile("dataforge_test", ".df")
|
||||
Global.io.writeEnvelopeFile(tmpPath, envelopeFromFile)
|
||||
|
||||
val binary = Global.io.readEnvelopeFile(tmpPath).data!!
|
||||
|
||||
var sum = 0.0
|
||||
binary.read {
|
||||
val dst = DoubleArray(100) { 0.0 }
|
||||
do {
|
||||
val flag = readAvailable(dst)
|
||||
println("$flag : ${dst[0]}")
|
||||
dst.map {
|
||||
sum += it
|
||||
}
|
||||
} while (flag != -1)
|
||||
}
|
||||
assertTrue(sum > 0.0)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user