aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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) {