commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [4/9] commons-cli git commit: Added tests for partial matching enable/disable
Date Mon, 31 Jul 2017 15:51:46 GMT
Added tests for partial matching enable/disable


Project: http://git-wip-us.apache.org/repos/asf/commons-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-cli/commit/4f17a89a
Tree: http://git-wip-us.apache.org/repos/asf/commons-cli/tree/4f17a89a
Diff: http://git-wip-us.apache.org/repos/asf/commons-cli/diff/4f17a89a

Branch: refs/heads/master
Commit: 4f17a89ad04bcf718aeac43d202f8c261ce0b796
Parents: bdb4a09
Author: Rubin Simons <rubin@raaftech.com>
Authored: Fri Jun 23 13:04:59 2017 +0200
Committer: Rubin Simons <rubin@raaftech.com>
Committed: Fri Jun 23 13:04:59 2017 +0200

----------------------------------------------------------------------
 .../commons/cli/DisablePartialMatchingTest.java | 58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-cli/blob/4f17a89a/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java b/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java
new file mode 100644
index 0000000..0457bac
--- /dev/null
+++ b/src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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 org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class DisablePartialMatchingTest
+{
+    @Test
+    public void testDisablePartialMatching() throws Exception
+    {
+        CommandLineParser parser = new DefaultParser(false);
+
+        final Options options = new Options();
+
+        options.addOption(new Option("d", "debug", false, "Turn on debug."));
+        options.addOption(new Option("e", "extract", false, "Turn on extract."));
+
+        CommandLine line = parser.parse(options, new String[]{"-de"});
+
+        assertTrue("There should be an option debug in any case...", line.hasOption("debug"));
+        assertTrue("There should be an extract option because partial matching is off", line.hasOption("extract"));
+    }
+
+    @Test
+    public void testRegularPartialMatching() throws Exception
+    {
+        CommandLineParser parser = new DefaultParser();
+
+        final Options options = new Options();
+
+        options.addOption(new Option("d", "debug", false, "Turn on debug."));
+        options.addOption(new Option("e", "extract", false, "Turn on extract."));
+
+        CommandLine line = parser.parse(options, new String[]{"-de"});
+
+        assertTrue("There should be an option debug in any case...", line.hasOption("debug"));
+        assertFalse("There should not be an extract option because partial matching only
selects debug", line.hasOption("extract"));
+    }
+}


Mime
View raw message