Author: ebourg
Date: Fri May 30 04:21:34 2008
New Revision: 661652
URL: http://svn.apache.org/viewvc?rev=661652&view=rev
Log:
Improved test coverage for HelpFormatter.printHelp() with a null or empty
cmdLineSyntax parameter
Modified:
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/HelpFormatterTest.java
Modified:
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/HelpFormatterTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/HelpFormatterTest.java?rev=661652&r1=661651&r2=661652&view=diff
==============================================================================
---
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/HelpFormatterTest.java
(original)
+++
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/HelpFormatterTest.java
Fri May 30 04:21:34 2008
@@ -155,6 +155,31 @@
assertEquals("multiple wrapped options", expected, sb.toString());
}
+ public void testPrintHelpWithEmptySyntax()
+ {
+ HelpFormatter formatter = new HelpFormatter();
+ try
+ {
+ formatter.printHelp(null, new Options());
+ fail("null command line syntax should be rejected");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ formatter.printHelp("", new Options());
+ fail("empty command line syntax should be rejected");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+
public void testAutomaticUsage() throws Exception
{
HelpFormatter hf = new HelpFormatter();
@@ -295,13 +320,7 @@
public void testRtrim()
{
- HelpFormatter formatter = new HelpFormatter()
- {
- public String rtrim(String s)
- {
- return super.rtrim(s);
- }
- };
+ HelpFormatter formatter = new HelpFormatter();
assertEquals(null, formatter.rtrim(null));
assertEquals("", formatter.rtrim(""));