Dev zelenyy #26
@ -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
File binary test already exists in https://github.com/mipt-npm/dataforge-core/blob/dev/dataforge-io/src/jvmTest/kotlin/hep/dataforge/io/FileBinaryTest.kt