commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/util ComparatorsTest.java
Date Tue, 20 Apr 2004 21:48:59 GMT
roxspring    2004/04/20 14:48:59

  Modified:    cli/src/test/org/apache/commons/cli2/util Tag:
                        RESEARCH_CLI_2_ROXSPRING ComparatorsTest.java
  Log:
  Added tests for requiredFirst(..) and requiredLast(..).
  Fixed tests to correctly test order.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +68 -55    jakarta-commons/cli/src/test/org/apache/commons/cli2/util/Attic/ComparatorsTest.java
  
  Index: ComparatorsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/util/Attic/ComparatorsTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ComparatorsTest.java	1 Apr 2004 21:13:36 -0000	1.1.2.2
  +++ ComparatorsTest.java	20 Apr 2004 21:48:59 -0000	1.1.2.3
  @@ -36,39 +36,36 @@
       public void testGroupFirst() {
           final Option o1 = GroupTest.buildAntGroup();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = GroupTest.buildApachectlGroup();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.groupFirst());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o1, o3, o2),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   
       public void testGroupLast() {
           final Option o1 = GroupTest.buildAntGroup();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = GroupTest.buildApachectlGroup();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.groupLast());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o2, o1, o3),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
               list);
       }
   
       public void testSwitchFirst() {
           final Option o1 = SwitchTest.buildDisplaySwitch();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = new SwitchBuilder().withName("hidden").create();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.switchFirst());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o1, o3, o2),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   
  @@ -76,116 +73,132 @@
           final Option o1 = SwitchTest.buildDisplaySwitch();
           final Option o2 = ParentTest.buildLibParent();
           final Option o3 = new SwitchBuilder().withName("hidden").create();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.switchLast());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o2, o1, o3),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
               list);
       }
   
       public void testCommandFirst() {
           final Option o1 = CommandTest.buildCommitCommand();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = CommandTest.buildStartCommand();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.commandFirst());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o1, o3, o2),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   
       public void testCommandLast() {
           final Option o1 = CommandTest.buildCommitCommand();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = CommandTest.buildStartCommand();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.commandLast());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o1, o3, o2),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
               list);
       }
   
       public void testDefaultOptionFirst() {
           final Option o1 = DefaultOptionTest.buildHelpOption();
  -        final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = DefaultOptionTest.buildXOption();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final Option o2 = CommandTest.buildCommitCommand();
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.defaultOptionFirst());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o1, o3, o2),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   
       public void testDefaultOptionLast() {
           final Option o1 = DefaultOptionTest.buildHelpOption();
  -        final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = DefaultOptionTest.buildXOption();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final Option o2 = CommandTest.buildCommitCommand();
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.defaultOptionLast());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o2, o1, o3),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
               list);
       }
   
       public void testNamedFirst() {
           final Option o1 = DefaultOptionTest.buildHelpOption();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = DefaultOptionTest.buildXOption();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
  -        Collections.sort(list, Comparators.namedFirst("--lib"));
  +        Collections.sort(list, Comparators.namedFirst("--help"));
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o1, o3, o2),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   
       public void testNamedLast() {
           final Option o1 = DefaultOptionTest.buildHelpOption();
           final Option o2 = ParentTest.buildLibParent();
  -        final Option o3 = DefaultOptionTest.buildXOption();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final List list = OptionTestCase.list(o1, o2);
   
  -        Collections.sort(list, Comparators.namedLast("--lib"));
  +        Collections.sort(list, Comparators.namedLast("--help"));
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o2, o1, o3),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
               list);
       }
   
       public void testPreferredNameFirst() {
  -        final Option o1 = ParentTest.buildLibParent();
  -        final Option o2 = DefaultOptionTest.buildHelpOption();
  -        final Option o3 = DefaultOptionTest.buildXOption();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final Option o1 = DefaultOptionTest.buildHelpOption();
  +        final Option o2 = ParentTest.buildLibParent();
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.preferredNameFirst());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o2, o1, o3),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   
       public void testPreferredNameLast() {
  -        final Option o1 = ParentTest.buildLibParent();
  -        final Option o2 = DefaultOptionTest.buildHelpOption();
  -        final Option o3 = DefaultOptionTest.buildXOption();
  -        final List list = OptionTestCase.list(o1, o2, o3);
  +        final Option o1 = DefaultOptionTest.buildHelpOption();
  +        final Option o2 = ParentTest.buildLibParent();
  +        final List list = OptionTestCase.list(o1, o2);
   
           Collections.sort(list, Comparators.preferredNameLast());
   
  -        OptionTestCase.assertContentsEqual(
  -            OptionTestCase.list(o2, o1, o3),
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
  +            list);
  +    }
  +
  +    public void testRequiredFirst() {
  +        final Option o1 = DefaultOptionTest.buildHelpOption();
  +        final Option o2 = DefaultOptionTest.buildXOption();
  +        final List list = OptionTestCase.list(o1, o2);
  +
  +        Collections.sort(list, Comparators.requiredFirst());
  +
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o2, o1),
  +            list);
  +    }
  +
  +    public void testRequiredLast() {
  +        final Option o1 = DefaultOptionTest.buildHelpOption();
  +        final Option o2 = DefaultOptionTest.buildXOption();
  +        final List list = OptionTestCase.list(o1, o2);
  +
  +        Collections.sort(list, Comparators.requiredLast());
  +
  +        OptionTestCase.assertListContentsEqual(
  +            OptionTestCase.list(o1, o2),
               list);
       }
   }
  
  
  

---------------------------------------------------------------------
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