Commit before merge, two test failed
This commit is contained in:
parent
6c4430a5a4
commit
1dd2b689ca
@ -4,6 +4,7 @@ import hep.dataforge.context.Global
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class FileBinaryTest {
|
class FileBinaryTest {
|
||||||
val envelope = Envelope {
|
val envelope = Envelope {
|
||||||
@ -53,4 +54,30 @@ class FileBinaryTest {
|
|||||||
assertEquals(binary.size.toInt(), binary.toBytes().size)
|
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() }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -45,23 +45,23 @@ class FileEnvelopeTest {
|
|||||||
val tmpPath = Files.createTempFile("dataforge_test", ".df")
|
val tmpPath = Files.createTempFile("dataforge_test", ".df")
|
||||||
Global.io.writeEnvelopeFile(tmpPath, envelope)
|
Global.io.writeEnvelopeFile(tmpPath, envelope)
|
||||||
println(tmpPath.toUri())
|
println(tmpPath.toUri())
|
||||||
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)
|
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)!!
|
||||||
assertTrue { envelope.contentEquals(restored) }
|
assertTrue { envelope.contentEquals(restored) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFileWriteTagless() {
|
fun testFileWriteTagless() {
|
||||||
val tmpPath = Files.createTempFile("dataforge_test", ".df")
|
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 }
|
assertTrue { tmpPath.toFile().length() > 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFileWriteReadTagless() {
|
fun testFileWriteReadTagless() {
|
||||||
val tmpPath = Files.createTempFile("dataforge_test", ".df")
|
val tmpPath = Files.createTempFile("dataforge_test", ".df")
|
||||||
Global.io.writeEnvelopeFile(tmpPath, envelope, formatFactory = TaglessEnvelopeFormat)
|
Global.io.writeEnvelopeFile(tmpPath, envelope, format = TaglessEnvelopeFormat)
|
||||||
println(tmpPath.toUri())
|
println(tmpPath.toUri())
|
||||||
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath, formatFactory = TaglessEnvelopeFormat)
|
val restored: Envelope = Global.io.readEnvelopeFile(tmpPath)!!
|
||||||
assertTrue { envelope.contentEquals(restored) }
|
assertTrue { envelope.contentEquals(restored) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user