jkeyes 2004/03/10 16:26:57
Modified: cli/src/test/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING ArgumentTest.java
Log:
- increase our ArgumentImpl test coverage
Revision Changes Path
No revision
No revision
1.1.2.11 +80 -16
jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java
Index: ArgumentTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- ArgumentTest.java 6 Mar 2004 22:21:24 -0000 1.1.2.10
+++ ArgumentTest.java 11 Mar 2004 00:26:57 -0000 1.1.2.11
@@ -147,22 +147,86 @@
}
public void testNew() {
- try {
- new ArgumentImpl(
- "limit",
- "the last acceptable date",
- 10,
- 5,
- '=',
- '\0',
- new DateValidator(DateValidatorTest.YYYY_MM_YY),
- null,
- null,
- 0);
- } catch (IllegalArgumentException e) {
- assertEquals(
- resources.getMessage("cli.error.minimum.exceeds.maximum"),
- e.getMessage());
+ {
+ try {
+ new ArgumentImpl(
+ "limit",
+ "the last acceptable date",
+ 10,
+ 5,
+ '=',
+ '\0',
+ new DateValidator(DateValidatorTest.YYYY_MM_YY),
+ null,
+ null,
+ 0);
+ } catch (IllegalArgumentException e) {
+ assertEquals(
+ resources.getMessage("cli.error.minimum.exceeds.maximum"),
+ e.getMessage());
+ }
+ }
+ {
+ ArgumentImpl arg = new ArgumentImpl(
+ null,
+ "the last acceptable date",
+ 5,
+ 5,
+ '=',
+ '\0',
+ new DateValidator(DateValidatorTest.YYYY_MM_YY),
+ null,
+ null,
+ 0);
+ assertEquals("wrong arg name", "arg", arg.getPreferredName());
+ }
+
+ {
+ List defaults = new ArrayList();
+
+ try {
+ ArgumentImpl arg = new ArgumentImpl(
+ null,
+ "the last acceptable date",
+ 1,
+ 1,
+ '=',
+ '\0',
+ new DateValidator(DateValidatorTest.YYYY_MM_YY),
+ null,
+ defaults,
+ 0);
+ }
+ catch(IllegalArgumentException exp) {
+ assertEquals(
+ resources.getMessage("cli.error.too.few.defaults"),
+ exp.getMessage());
+ }
+ }
+
+ {
+ try {
+ List defaults = new ArrayList();
+ defaults.add("1");
+ defaults.add("2");
+
+ ArgumentImpl arg = new ArgumentImpl(
+ null,
+ "the last acceptable date",
+ 1,
+ 1,
+ '=',
+ '\0',
+ new DateValidator(DateValidatorTest.YYYY_MM_YY),
+ null,
+ defaults,
+ 0);
+ }
+ catch(IllegalArgumentException exp) {
+ assertEquals(
+ resources.getMessage("cli.error.too.many.defaults"),
+ exp.getMessage());
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]