commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r544744 - in /jakarta/commons/proper/cli/branches/cli-1.0.x/src: java/org/apache/commons/cli/Util.java test/org/apache/commons/cli/UtilTest.java test/org/apache/commons/cli/bug/BugCLI133Test.java
Date Wed, 06 Jun 2007 07:10:31 GMT
Author: bayard
Date: Wed Jun  6 00:10:30 2007
New Revision: 544744

URL: http://svn.apache.org/viewvc?view=rev&rev=544744
Log:
Applying the patches from Brian Egge in CLI-133

Added:
    jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/UtilTest.java
  (with props)
    jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/bug/BugCLI133Test.java
  (with props)
Modified:
    jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Util.java

Modified: jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Util.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Util.java?view=diff&rev=544744&r1=544743&r2=544744
==============================================================================
--- jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Util.java
(original)
+++ jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Util.java
Wed Jun  6 00:10:30 2007
@@ -33,6 +33,9 @@
      */
     static String stripLeadingHyphens(String str)
     {
+        if (str == null) {
+            return null;
+        }
         if (str.startsWith("--"))
         {
             return str.substring(2, str.length());

Added: jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/UtilTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/UtilTest.java?view=auto&rev=544744
==============================================================================
--- jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/UtilTest.java
(added)
+++ jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/UtilTest.java
Wed Jun  6 00:10:30 2007
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli;
+
+import junit.framework.TestCase;
+
+/**
+ * @author brianegge
+ */
+public class UtilTest extends TestCase {
+    public void testStripLeadingHyphens() {
+        assertEquals("f", Util.stripLeadingHyphens("-f"));
+        assertEquals("foo", Util.stripLeadingHyphens("--foo"));
+        assertNull(Util.stripLeadingHyphens(null));
+    }
+}

Propchange: jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/UtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/bug/BugCLI133Test.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/bug/BugCLI133Test.java?view=auto&rev=544744
==============================================================================
--- jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/bug/BugCLI133Test.java
(added)
+++ jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/bug/BugCLI133Test.java
Wed Jun  6 00:10:30 2007
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli.bug;
+
+import junit.framework.TestCase;
+import org.apache.commons.cli.*;
+
+/**
+ * @author brianegge
+ */
+public class BugCLI133Test extends TestCase {
+    public void testOrder() throws ParseException {
+        Option optionA = new Option("a", "first");
+        Options opts = new Options();
+        opts.addOption(optionA);
+        PosixParser posixParser = new PosixParser();
+        CommandLine line = posixParser.parse(opts, null);
+        assertFalse(line.hasOption(null));
+    }
+}

Propchange: jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/bug/BugCLI133Test.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message