You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/17 01:51:43 UTC

[GitHub] [iotdb] qiaojialin commented on a diff in pull request #5848: [IOTDB-3095] Use antlr to parse PartialPath/Path

qiaojialin commented on code in PR #5848:
URL: https://github.com/apache/iotdb/pull/5848#discussion_r874287827


##########
node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java:
##########
@@ -23,8 +23,496 @@
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.fail;
+
 public class PartialPathTest {
 
+  @Test
+  public void testLegalPath() throws IllegalPathException {
+    String[] nodes;
+    // empty path
+    PartialPath a = new PartialPath("", false);
+    Assert.assertEquals("", a.getFullPath());
+    Assert.assertEquals(0, a.getNodes().length);
+
+    // suffix path
+    PartialPath b = new PartialPath("s1");
+    Assert.assertEquals("s1", b.getFullPath());
+    Assert.assertEquals("s1", b.getNodes()[0]);
+
+    // normal node
+    PartialPath c = new PartialPath("root.sg.a");
+    Assert.assertEquals("root.sg.a", c.getFullPath());
+    nodes = new String[] {"root", "sg", "a"};
+    checkNodes(nodes, c.getNodes());
+
+    // quoted node
+    PartialPath d = new PartialPath("root.sg.`a.b`");
+    Assert.assertEquals("root.sg.`a.b`", d.getFullPath());
+    nodes = new String[] {"root", "sg", "`a.b`"};
+    checkNodes(nodes, d.getNodes());
+
+    PartialPath e = new PartialPath("root.sg.`a.``b`");
+    Assert.assertEquals("root.sg.`a.``b`", e.getFullPath());
+    nodes = new String[] {"root", "sg", "`a.``b`"};
+    checkNodes(nodes, e.getNodes());
+
+    PartialPath f = new PartialPath("root.`sg\"`.`a.``b`");
+    Assert.assertEquals("root.`sg\"`.`a.``b`", f.getFullPath());
+    nodes = new String[] {"root", "`sg\"`", "`a.``b`"};
+    checkNodes(nodes, f.getNodes());
+
+    PartialPath g = new PartialPath("root.sg.`a.b\\\\`");
+    Assert.assertEquals("root.sg.`a.b\\\\`", g.getFullPath());
+    nodes = new String[] {"root", "sg", "`a.b\\\\`"};
+    checkNodes(nodes, g.getNodes());
+
+    // quoted node of digits
+    PartialPath h = new PartialPath("root.sg.`111`");
+    Assert.assertEquals("root.sg.`111`", h.getFullPath());
+    nodes = new String[] {"root", "sg", "`111`"};
+    checkNodes(nodes, h.getNodes());
+
+    // quoted node of key word
+    PartialPath i = new PartialPath("root.sg.`select`");
+    Assert.assertEquals("root.sg.`select`", i.getFullPath());
+    nodes = new String[] {"root", "sg", "`select`"};

Review Comment:
   +1 for this case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org