v0.8.2 #80
@ -4,6 +4,7 @@
|
||||
|
||||
### Added
|
||||
- Name index comparator
|
||||
- Specialized ByteArrayValue
|
||||
|
||||
### Changed
|
||||
- DataSink `branch` is replaced with `putAll` to avoid confusion with DataTree methods
|
||||
@ -15,7 +16,8 @@
|
||||
### Fixed
|
||||
- `listOfScheme` and `listOfConvertable` delegates provides correct items order.
|
||||
- Scheme meta setter works with proper sub-branch.
|
||||
-
|
||||
- NameToken.parse improper work with indices
|
||||
|
||||
|
||||
### Security
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class NameToken(public val body: String, public val index: String? = null
|
||||
public fun parse(string: String): NameToken {
|
||||
val body = string.substringBefore('[')
|
||||
val index = string.substringAfter('[', "")
|
||||
if (index.isNotEmpty() && index.endsWith(']')) error("NameToken with index must end with ']'")
|
||||
if (index.isNotEmpty() && !index.endsWith(']')) error("NameToken with index must end with ']'")
|
||||
return NameToken(body, index.removeSuffix("]"))
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package space.kscience.dataforge.names
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.*
|
||||
|
||||
class NameTest {
|
||||
@Test
|
||||
@ -50,4 +47,19 @@ class NameTest {
|
||||
val name = Name.parse("a.b.c")
|
||||
assertEquals("a.b".parseAsName(), name.cutLast())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun tokenParseTest(){
|
||||
val token1 = NameToken.parse("token[index]")
|
||||
assertEquals("token", token1.body)
|
||||
assertEquals("index", token1.index)
|
||||
|
||||
val token2 = NameToken.parse("token-body")
|
||||
assertEquals("token-body", token2.body)
|
||||
assertEquals("", token2.index)
|
||||
|
||||
assertFails {
|
||||
NameToken.parse("token[22")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user