geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r409491 - /geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserTest.java
Date Thu, 25 May 2006 22:25:50 GMT
Author: jdillon
Date: Thu May 25 15:25:49 2006
New Revision: 409491

URL: http://svn.apache.org/viewvc?rev=409491&view=rev
Log:
Improve test effectiveness by checking types and values

Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserTest.java

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserTest.java?rev=409491&r1=409490&r2=409491&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserTest.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserTest.java
Thu May 25 15:25:49 2006
@@ -52,8 +52,7 @@
 
         ASTCommandLine cl = parse(input);
 
-        // Children array is lazy created, so when no children this is null
-        assertNull(cl.children);
+        assertEquals(0, cl.jjtGetNumChildren());
     }
 
     public void testSingleComment2() throws Exception {
@@ -61,8 +60,7 @@
 
         ASTCommandLine cl = parse(input);
 
-        // Children array is lazy created, so when no children this is null
-        assertNull(cl.children);
+        assertEquals(0, cl.jjtGetNumChildren());
     }
 
     public void testSingleComment3() throws Exception {
@@ -70,8 +68,7 @@
 
         ASTCommandLine cl = parse(input);
 
-        // Children array is lazy created, so when no children this is null
-        assertNull(cl.children);
+        assertEquals(0, cl.jjtGetNumChildren());
     }
 
     //
@@ -83,9 +80,21 @@
 
         ASTCommandLine cl = parse(input);
 
-        //
-        // TODO: Verify 3 plain strings
-        //
+        // One expression
+        assertEquals(1, cl.jjtGetNumChildren());
+
+        // 3 plain strings
+        Node child = cl.jjtGetChild(0);
+        assertEquals(3, child.jjtGetNumChildren());
+
+        for (int i=0; i<3; i++ ) {
+            Node node = child.jjtGetChild(i);
+            assertEquals(ASTPlainString.class, node.getClass());
+        }
+
+        assertEquals("a", ((ASTPlainString)child.jjtGetChild(0)).getValue());
+        assertEquals("b", ((ASTPlainString)child.jjtGetChild(1)).getValue());
+        assertEquals("c", ((ASTPlainString)child.jjtGetChild(2)).getValue());
     }
 
     public void testStrings2() throws Exception {
@@ -93,9 +102,22 @@
 
         ASTCommandLine cl = parse(input);
 
-        //
-        // TODO: Verify 4 plain strings
-        //
+        // One expression
+        assertEquals(1, cl.jjtGetNumChildren());
+
+        // 4 plain strings
+        Node child = cl.jjtGetChild(0);
+        assertEquals(4, child.jjtGetNumChildren());
+
+        for (int i=0; i<4; i++ ) {
+            Node node = child.jjtGetChild(i);
+            assertEquals(ASTPlainString.class, node.getClass());
+        }
+
+        assertEquals("a", ((ASTPlainString)child.jjtGetChild(0)).getValue());
+        assertEquals("-b", ((ASTPlainString)child.jjtGetChild(1)).getValue());
+        assertEquals("--c", ((ASTPlainString)child.jjtGetChild(2)).getValue());
+        assertEquals("d", ((ASTPlainString)child.jjtGetChild(3)).getValue());
     }
 
     public void testQuotedStrings1() throws Exception {
@@ -103,9 +125,26 @@
 
         ASTCommandLine cl = parse(input);
 
-        //
-        // TODO: Verify 2 plain strings + 1 quoted
-        //
+        // One expression
+        assertEquals(1, cl.jjtGetNumChildren());
+
+        Node child = cl.jjtGetChild(0);
+        assertEquals(3, child.jjtGetNumChildren());
+
+        // Verify 2 plain strings + 1 quoted
+        Node node;
+
+        node = child.jjtGetChild(0);
+        assertEquals(ASTPlainString.class, node.getClass());
+        assertEquals("a", ((StringSupport)node).getValue());
+
+        node = child.jjtGetChild(1);
+        assertEquals(ASTQuotedString.class, node.getClass());
+        assertEquals("\"b -c\"", ((StringSupport)node).getValue());
+
+        node = child.jjtGetChild(2);
+        assertEquals(ASTPlainString.class, node.getClass());
+        assertEquals("d", ((StringSupport)node).getValue());
     }
 
     public void testOpaqueStrings1() throws Exception {
@@ -113,9 +152,25 @@
 
         ASTCommandLine cl = parse(input);
 
-        //
-        // TODO: Verify 2 plain strings + 1 opaque
-        //
+        // One expression
+        assertEquals(1, cl.jjtGetNumChildren());
+
+        Node child = cl.jjtGetChild(0);
+        assertEquals(3, child.jjtGetNumChildren());
+
+        // Verify 2 plain strings + 1 opaque
+        Node node;
+
+        node = child.jjtGetChild(0);
+        assertEquals(ASTPlainString.class, node.getClass());
+        assertEquals("a", ((StringSupport)node).getValue());
+
+        node = child.jjtGetChild(1);
+        assertEquals(ASTOpaqueString.class, node.getClass());
+        assertEquals("'b -c'", ((StringSupport)node).getValue());
+
+        node = child.jjtGetChild(2);
+        assertEquals(ASTPlainString.class, node.getClass());
     }
 
     //
@@ -126,6 +181,8 @@
         String input = "a b c; d e f";
 
         ASTCommandLine cl = parse(input);
+
+        assertEquals(2, cl.jjtGetNumChildren());
 
         //
         // TODO: Verify 2 expressions



Mime
View raw message