Add test for data_len in DF03 envelope

This commit is contained in:
Mikhail Zelenyy 2019-11-01 13:25:25 +03:00
parent 72399e852a
commit 355131efc1

View File

@ -1,9 +1,10 @@
package hep.dataforge.io
import hep.dataforge.context.Global
import java.nio.ByteBuffer
import java.nio.file.Files
import kotlin.test.Test
import kotlin.test.assertTrue
import java.util.*
import kotlin.test.*
class FileEnvelopeTest {
@ -28,4 +29,28 @@ class FileEnvelopeTest {
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)
assertTrue { envelope.contentEquals(restored) }
}
@Test
fun testDataSize() {
val tmpPath = Files.createTempFile("dataforge_test", ".df")
Global.io.writeEnvelopeFile(tmpPath,envelope)
println(tmpPath.toUri())
val scan = Scanner(tmpPath.toFile().inputStream()).useDelimiter("\n").nextLine()
println(scan)
val format = scan.slice(2..5)
if (format == "DF03"){
val buff = ByteBuffer.allocate(4)
buff.put(scan.slice(12..15).toByteArray())
buff.flip()
val size = buff.int
println(size)
assertEquals(8, size)
}
else{
fail("Format $format don't have test")
}
}
}