commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang StringsTrimEmptyTest.java
Date Sat, 13 Jul 2002 05:49:50 GMT
bayard      2002/07/12 22:49:50

  Modified:    lang/src/test/org/apache/commons/lang
                        StringsTrimEmptyTest.java
  Log:
  Added stripAll unit tests. Also a private method for confirming equality
  of arrays, must be a way to do this in JUnit.
  
  Revision  Changes    Path
  1.5       +27 -1     jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsTrimEmptyTest.java
  
  Index: StringsTrimEmptyTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsTrimEmptyTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringsTrimEmptyTest.java	10 Jul 2002 22:35:29 -0000	1.4
  +++ StringsTrimEmptyTest.java	13 Jul 2002 05:49:50 -0000	1.5
  @@ -157,6 +157,32 @@
           assertEquals(fooLeftSpace, Strings.stripEnd(fooLeftSpace, " "));
           assertEquals(fooLeftDots, Strings.stripEnd(fooLeftDots, "."));
   
  +        // test stripAll method, merely an array version of the above strip
  +        String[] empty = new String[0];
  +        String[] fooSpace = new String[] { foo2Space, fooLeftSpace, fooRightSpace };
  +        String[] fooDots = new String[] { foo2Dots, fooLeftDots, fooRightDots };
  +        String[] foo = new String[] { FOO, FOO, FOO };
  +
  +        assertArrayEquals(empty, Strings.stripAll(empty));
  +        assertArrayEquals(foo, Strings.stripAll(fooSpace));
  +        assertArrayEquals(foo, Strings.stripAll(fooDots, "."));
  +    }
  +
  +    private void assertArrayEquals(Object[] o1, Object[] o2) {
  +        if(o1 == null) {
  +            assertEquals(o1,o2);
  +            return;
  +        }
  +        assertEquals("Length not equal. ", o1.length, o2.length);
  +        int sz = o1.length;
  +        for(int i=0; i<sz; i++) {
  +            if(o1[i] instanceof Object[]) {
  +                // do an assert equals on type....
  +                assertArrayEquals( (Object[]) o1[i], (Object[]) o2[i] );
  +            } else {
  +                assertEquals(o1[i], o2[i]);
  +            }
  +        }
       }
   
   }
  
  
  

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


Mime
View raw message