aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-01-30 08:03:46 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2024-01-30 08:03:46 +0100
commit491f31ec5cb423263d569056e57100a514f218c0 (patch)
tree0b0bd9124ed16ad98920f206572c5e36181f729d /vespajlib
parent659e5d74ee74493c273fb9f66b35992732c5317b (diff)
- 0 prefixed numbers should not be considered numeric."
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/impl/Label.java1
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TensorAddressTestCase.java4
2 files changed, 4 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/impl/Label.java b/vespajlib/src/main/java/com/yahoo/tensor/impl/Label.java
index a09c0223d28..4b832bc7dc8 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/impl/Label.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/impl/Label.java
@@ -48,6 +48,7 @@ public class Label {
}
private static boolean validNumericIndex(String s) {
+ if ((s.length() == 0) || (s.length() > 1 && s.charAt(0) == '0')) return false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if ((c < '0') || (c > '9')) return false;
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorAddressTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorAddressTestCase.java
index 472ebca2360..204d5447b91 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TensorAddressTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorAddressTestCase.java
@@ -10,6 +10,7 @@ import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test for tensor address.
@@ -38,6 +39,7 @@ public class TensorAddressTestCase {
void testInEquality() {
notEqual(ofLabels("1"), ofLabels("2"));
notEqual(of(1), of(2));
+ notEqual(ofLabels("1"), ofLabels("01"));
}
@Test
void testDimensionsEffectsEqualityAndHash() {
@@ -50,7 +52,7 @@ public class TensorAddressTestCase {
TensorAddress s2 = ofLabels("1", "2");
assertNotEquals(s1, s2);
assertEquals(-1, s1.numericLabel(1));
- assertEquals(null, s1.label(1));
+ assertNull(s1.label(1));
}
private static void verifyWithLabel(int dimensions) {