Dev zelenyy 2 #29

Closed
Zelenyy wants to merge 8 commits from dev-zelenyy-2 into dev
2 changed files with 31 additions and 4 deletions
Showing only changes of commit 1dd2b689ca - Show all commits

View File

@ -4,6 +4,7 @@ import hep.dataforge.context.Global
import java.nio.file.Files
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class FileBinaryTest {
val envelope = Envelope {
@ -53,4 +54,30 @@ class FileBinaryTest {
assertEquals(binary.size.toInt(), binary.toBytes().size)
}
@Test
fun testMultyPartFileData() {
val envelopeList = (0..5).map {
val dataFile = Files.createTempFile("dataforge_test_bin_$it", ".bin")
dataFile.toFile().writeText(DoubleArray(80000) { it.toDouble() }.joinToString())
val envelopeFromFile = Envelope {
meta {
"a" put "AAA"
"b" put 22.2
}
dataType = "hep.dataforge.satellite"
dataID = "cellDepositTest$it" // добавил только что
data = dataFile.asBinary()
}
envelopeFromFile
}
val envelope = Envelope {
multipart(TaggedEnvelopeFormat, envelopeList)
}
println(envelopeList.map { it.data?.size }.joinToString(" "))
println(envelope.data?.size)
assertTrue { envelope.data!!.size > envelopeList.map { it.data!!.size }.sum() }
}
}

View File

@ -45,23 +45,23 @@ class FileEnvelopeTest {
val tmpPath = Files.createTempFile("dataforge_test", ".df")
Global.io.writeEnvelopeFile(tmpPath, envelope)
println(tmpPath.toUri())
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)!!
assertTrue { envelope.contentEquals(restored) }
}
@Test
fun testFileWriteTagless() {
val tmpPath = Files.createTempFile("dataforge_test", ".df")
Global.io.writeEnvelopeFile(tmpPath, envelope, formatFactory = TaglessEnvelopeFormat)
Global.io.writeEnvelopeFile(tmpPath, envelope, format = TaglessEnvelopeFormat)
assertTrue { tmpPath.toFile().length() > 0 }
}
@Test
fun testFileWriteReadTagless() {
val tmpPath = Files.createTempFile("dataforge_test", ".df")
Global.io.writeEnvelopeFile(tmpPath, envelope, formatFactory = TaglessEnvelopeFormat)
Global.io.writeEnvelopeFile(tmpPath, envelope, format = TaglessEnvelopeFormat)
println(tmpPath.toUri())
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath, formatFactory = TaglessEnvelopeFormat)
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)!!
assertTrue { envelope.contentEquals(restored) }
}