Dev zelenyy #26

Closed
Zelenyy wants to merge 8 commits from dev-zelenyy into dev
Showing only changes of commit 72399e852a - Show all commits

View File

@ -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
altavir commented 2019-11-05 20:01:29 +03:00 (Migrated from github.com)
Review
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
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)
}
}