Add ByteArrayValue

This commit is contained in:
Alexander Nozik 2024-04-16 15:35:59 +03:00
parent 1c60453244
commit a720b63d70
3 changed files with 25 additions and 1 deletions

View File

@ -8,7 +8,7 @@ plugins {
allprojects { allprojects {
group = "space.kscience" group = "space.kscience"
version = "0.8.1" version = "0.8.2"
} }
subprojects { subprojects {

View File

@ -128,6 +128,10 @@ public interface MutableMeta : Meta, MutableMetaProvider {
setValue(Name.parse(this), array.asValue()) setValue(Name.parse(this), array.asValue())
} }
public infix fun String.put(array: ByteArray) {
setValue(Name.parse(this), array.asValue())
}
public infix fun String.put(repr: MetaRepr) { public infix fun String.put(repr: MetaRepr) {
set(Name.parse(this), repr.toMeta()) set(Name.parse(this), repr.toMeta())
} }

View File

@ -1,4 +1,24 @@
package space.kscience.dataforge.values package space.kscience.dataforge.values
import space.kscience.dataforge.meta.DoubleArrayValue
import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.meta.doubleArray
import space.kscience.dataforge.meta.get
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class DoubleArrayValue { class DoubleArrayValue {
@Test
fun doubleArrayWriteRead(){
val meta = Meta{
"doubleArray" put doubleArrayOf(1.0,2.0,3.0)
}
assertTrue {
meta["doubleArray"]?.value is DoubleArrayValue
}
assertEquals(2.0, meta["doubleArray"].doubleArray?.get(1))
}
} }