commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang LangTestSuite.java StringsSubstringTest.java StringsEqualsIndexOfTest.java StringsTrimEmptyTest.java StringsTest.java
Date Tue, 02 Jul 2002 22:03:29 GMT
scolebourne    2002/07/02 15:03:29

  Modified:    lang/src/test/org/apache/commons/lang StringsTest.java
  Added:       lang/src/test/org/apache/commons/lang LangTestSuite.java
                        StringsSubstringTest.java
                        StringsEqualsIndexOfTest.java
                        StringsTrimEmptyTest.java
  Log:
  Tests for Strings
  
  Revision  Changes    Path
  1.5       +2 -127    jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsTest.java
  
  Index: StringsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringsTest.java	2 Jul 2002 00:00:35 -0000	1.4
  +++ StringsTest.java	2 Jul 2002 22:03:29 -0000	1.5
  @@ -60,12 +60,13 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
  -
   /**
    * Unit tests {@link org.apache.commons.lang.Strings}.
    *
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
    * @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
  + * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
  + * @version $Id$
    */
   public class StringsTest extends TestCase
   {
  @@ -103,122 +104,6 @@
   
       //-----------------------------------------------------------------------
   
  -    public void testClean()
  -    {
  -        assertEquals("clean(String) failed",
  -                     FOO, Strings.clean(FOO + " "));
  -        assertEquals("clean(String) failed", "", Strings.clean(null));
  -    }
  -
  -    public void testTrim()
  -    {
  -        assertEquals("trim(String) failed", FOO, Strings.trim(FOO + " "));
  -        assertTrue("trim(String) failed", Strings.trim(null) == null);
  -    }
  -
  -    public void testIsValid()
  -    {
  -        assertTrue("isValid(String) failed",
  -                   Strings.isValid(FOO) && !Strings.isValid(""));
  -    }
  -
  -    public void testIsEmpty()
  -    {
  -        assertTrue("isEmpty(String) failed",
  -                   Strings.isEmpty("   ") && !Strings.isEmpty(FOO));
  -    }
  -
  -    public void testLeft()
  -    {
  -        assertSame(null, Strings.left(null, 0));
  -        assertSame(null, Strings.left(null, 2));
  -        assertSame("", Strings.left("", 0));
  -        assertSame("", Strings.left("", 2));
  -        assertEquals("", Strings.left("foobar", 0));
  -        assertEquals("foo", Strings.left("foobar", 3));
  -        assertSame("foobar", Strings.left("foobar", 80));
  -    }
  -    public void testLeftEx()
  -    {
  -        try {
  -            Strings.left("foobar", -1);
  -        } catch (IllegalArgumentException ex) {
  -            return;
  -        }
  -        fail();
  -    }
  -
  -    public void testRight()
  -    {
  -        assertSame(null, Strings.right(null, 0));
  -        assertSame(null, Strings.right(null, 2));
  -        assertSame("", Strings.right("", 0));
  -        assertSame("", Strings.right("", 2));
  -        assertEquals("", Strings.right("foobar", 0));
  -        assertEquals("bar", Strings.right("foobar", 3));
  -        assertSame("foobar", Strings.right("foobar", 80));
  -    }
  -    public void testRightEx()
  -    {
  -        try {
  -            Strings.right("foobar", -1);
  -        } catch (IllegalArgumentException ex) {
  -            return;
  -        }
  -        fail();
  -    }
  -
  -    public void testMid()
  -    {
  -        assertSame(null, Strings.mid(null, 3, 0));
  -        assertSame(null, Strings.mid(null, 3, 2));
  -        assertSame("", Strings.mid("", 0, 0));
  -        assertSame("", Strings.mid("", 0, 2));
  -        assertEquals("", Strings.mid("foobar", 3, 0));
  -        assertEquals("b", Strings.mid("foobar", 3, 1));
  -        assertEquals("foo", Strings.mid("foobar", 0, 3));
  -        assertEquals("bar", Strings.mid("foobar", 3, 3));
  -        assertEquals("foobar", Strings.mid("foobar", 0, 80));
  -        assertEquals("bar", Strings.mid("foobar", 3, 80));
  -    }
  -    public void testMidEx1()
  -    {
  -        try {
  -            Strings.mid("foobar", 0, -1);
  -        } catch (IllegalArgumentException ex) {
  -            return;
  -        }
  -        fail();
  -    }
  -
  -    public void testMidEx2()
  -    {
  -        try {
  -            Strings.mid("foobar", -1, 3);
  -        } catch (IndexOutOfBoundsException ex) {
  -            return;
  -        }
  -        fail();
  -    }
  -
  -    public void testMidEx3()
  -    {
  -        try {
  -            Strings.mid("foobar", 7, 3);
  -        } catch (IndexOutOfBoundsException ex) {
  -            return;
  -        }
  -        fail();
  -    }
  -
  -    public void testEquals()
  -    {
  -        assertTrue("equals(String, String) failed",
  -                   Strings.equals(null, null) &&
  -                   !Strings.equals(null, FOO) &&
  -                   Strings.equals(FOO, FOO));
  -    }
  -
       public void testCapitalizeFunctions()
       {
           assertEquals("firstLetterCaps(String) failed",
  @@ -360,16 +245,6 @@
           String iso = Strings.convertUnicodeToNative(unicode, "iso-2022-jp");
           assertEquals("Unicode conversions failed", input, iso);
   */
  -    }
  -
  -    public void testSubstring()
  -    {
  -        assertEquals("substring(String, int, int) failed",
  -                     FOO, Strings.substring(SENTENCE, 0, 3));
  -        assertEquals("substring(String, int, negative int) failed",
  -                     FOO, Strings.substring(SENTENCE, 0, -8));
  -        assertEquals("substring(String, int, overflow int) failed",
  -                     SENTENCE, Strings.substring(SENTENCE, 0, 80));
       }
   }
   
  
  
  
  1.1                  jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/LangTestSuite.java
  
  Index: LangTestSuite.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  /**
   * Test suite for the Lang package.
   *
   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
   * @version $Id: LangTestSuite.java,v 1.1 2002/07/02 22:03:29 scolebourne Exp $
   */
  public class LangTestSuite extends TestCase {
      
      /**
       * Construct a new instance.
       */
      public LangTestSuite(String name) {
          super(name);
      }
  
      /**
       * Command-line interface.
       */
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      /**
       * Get the suite of tests
       */
      public static Test suite() {
          TestSuite suite = new TestSuite();
          suite.addTest(NumberRangeTest.suite());
          suite.addTest(ObjectsTest.suite());
          suite.addTest(RandomStringsTest.suite());
          suite.addTest(SerializationTest.suite());
          suite.addTest(StringsTest.suite());
          suite.addTest(StringsTrimEmptyTest.suite());
          suite.addTest(StringsSubstringTest.suite());
          suite.addTest(StringsEqualsIndexOfTest.suite());
          return suite;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsSubstringTest.java
  
  Index: StringsSubstringTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  /**
   * Unit tests {@link org.apache.commons.lang.Strings} - Substring methods
   *
   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
   * @version $Id: StringsSubstringTest.java,v 1.1 2002/07/02 22:03:29 scolebourne Exp $
   */
  public class StringsSubstringTest extends TestCase {
      private static final String FOO = "foo";
      private static final String BAR = "bar";
      private static final String BAZ = "baz";
      private static final String FOOBAR = "foobar";
      private static final String SENTENCE = "foo bar baz";
  
      public StringsSubstringTest(String name) {
          super(name);
      }
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      public static TestSuite suite() {
          return new TestSuite(StringsSubstringTest.class);
      }
  
      protected void setUp() throws Exception {
          super.setUp();
      }
  
      protected void tearDown() throws Exception {
          super.tearDown();
      }
  
      //-----------------------------------------------------------------------
  
  
      public void testSubstring2() {
          assertEquals("", Strings.substring(SENTENCE, 80));
          assertEquals(BAZ, Strings.substring(SENTENCE, 8));
          assertEquals(BAZ, Strings.substring(SENTENCE, -3));
          assertEquals(SENTENCE, Strings.substring(SENTENCE, 0));
      }
      
      public void testSubstring3() {
          assertEquals("", Strings.substring(SENTENCE, 8, 6));
          assertEquals(FOO, Strings.substring(SENTENCE, 0, 3));
          assertEquals("o", Strings.substring(SENTENCE, -9, 3));
          assertEquals(FOO, Strings.substring(SENTENCE, 0, -8));
          assertEquals("o", Strings.substring(SENTENCE, -9, -8));
          assertEquals(SENTENCE, Strings.substring(SENTENCE, 0, 80));
      }
      
      public void testLeft() {
          assertSame(null, Strings.left(null, 0));
          assertSame(null, Strings.left(null, 2));
          assertSame("", Strings.left("", 0));
          assertSame("", Strings.left("", 2));
          assertEquals("", Strings.left(FOOBAR, 0));
          assertEquals(FOO, Strings.left(FOOBAR, 3));
          assertSame(FOOBAR, Strings.left(FOOBAR, 80));
      }
      
      public void testLeftEx() {
          try {
              Strings.left(FOOBAR, -1);
          } catch (IllegalArgumentException ex) {
              return;
          }
          fail();
      }
  
      public void testRight() {
          assertSame(null, Strings.right(null, 0));
          assertSame(null, Strings.right(null, 2));
          assertSame("", Strings.right("", 0));
          assertSame("", Strings.right("", 2));
          assertEquals("", Strings.right(FOOBAR, 0));
          assertEquals(BAR, Strings.right(FOOBAR, 3));
          assertSame(FOOBAR, Strings.right(FOOBAR, 80));
      }
      
      public void testRightEx() {
          try {
              Strings.right(FOOBAR, -1);
          } catch (IllegalArgumentException ex) {
              return;
          }
          fail();
      }
  
      public void testMid() {
          assertSame(null, Strings.mid(null, 3, 0));
          assertSame(null, Strings.mid(null, 3, 2));
          assertSame("", Strings.mid("", 0, 0));
          assertSame("", Strings.mid("", 0, 2));
          assertEquals("", Strings.mid(FOOBAR, 3, 0));
          assertEquals("b", Strings.mid(FOOBAR, 3, 1));
          assertEquals(FOO, Strings.mid(FOOBAR, 0, 3));
          assertEquals(BAR, Strings.mid(FOOBAR, 3, 3));
          assertEquals(FOOBAR, Strings.mid(FOOBAR, 0, 80));
          assertEquals(BAR, Strings.mid(FOOBAR, 3, 80));
      }
      
      public void testMidEx1() {
          try {
              Strings.mid(FOOBAR, 0, -1);
          } catch (IllegalArgumentException ex) {
              return;
          }
          fail();
      }
  
      public void testMidEx2() {
          try {
              Strings.mid(FOOBAR, -1, 3);
          } catch (IndexOutOfBoundsException ex) {
              return;
          }
          fail();
      }
  
      public void testMidEx3() {
          try {
              Strings.mid(FOOBAR, 7, 3);
          } catch (IndexOutOfBoundsException ex) {
              return;
          }
          fail();
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsEqualsIndexOfTest.java
  
  Index: StringsEqualsIndexOfTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  /**
   * Unit tests {@link org.apache.commons.lang.Strings} - Substring methods
   *
   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
   * @version $Id: StringsEqualsIndexOfTest.java,v 1.1 2002/07/02 22:03:29 scolebourne Exp
$
   */
  public class StringsEqualsIndexOfTest extends TestCase {
      private static final String FOO = "foo";
      private static final String BAR = "bar";
      private static final String FOOBAR = "foobar";
      private static final String[] FOOBAR_SUB_ARRAY = new String[] {"ob", "ba"};
  
      public StringsEqualsIndexOfTest(String name) {
          super(name);
      }
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      public static TestSuite suite() {
          return new TestSuite(StringsEqualsIndexOfTest.class);
      }
  
      protected void setUp() throws Exception {
          super.setUp();
      }
  
      protected void tearDown() throws Exception {
          super.tearDown();
      }
  
      //-----------------------------------------------------------------------
  
      public void testEquals() {
          assertEquals(true, Strings.equals(null, null));
          assertEquals(true, Strings.equals(FOO, FOO));
          assertEquals(true, Strings.equals(FOO, new String(new char[] { 'f', 'o', 'o' })));
          assertEquals(false, Strings.equals(FOO, new String(new char[] { 'f', 'O', 'O' })));
          assertEquals(false, Strings.equals(FOO, BAR));
          assertEquals(false, Strings.equals(FOO, null));
          assertEquals(false, Strings.equals(null, FOO));
      }
  
      public void testEqualsIgnoreCase() {
          assertEquals(true, Strings.equalsIgnoreCase(null, null));
          assertEquals(true, Strings.equalsIgnoreCase(FOO, FOO));
          assertEquals(true, Strings.equalsIgnoreCase(FOO, new String(new char[] { 'f', 'o',
'o' })));
          assertEquals(true, Strings.equalsIgnoreCase(FOO, new String(new char[] { 'f', 'O',
'O' })));
          assertEquals(false, Strings.equalsIgnoreCase(FOO, BAR));
          assertEquals(false, Strings.equalsIgnoreCase(FOO, null));
          assertEquals(false, Strings.equalsIgnoreCase(null, FOO));
      }
  
      public void testIndexOfAny() {
          assertEquals(-1, Strings.indexOfAny(null, null));
          assertEquals(-1, Strings.indexOfAny(null, FOOBAR_SUB_ARRAY));
          assertEquals(-1, Strings.indexOfAny(FOOBAR, null));
          assertEquals(2, Strings.indexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
          assertEquals(-1, Strings.indexOfAny(FOOBAR, new String[0]));
          assertEquals(-1, Strings.indexOfAny(FOOBAR, new String[] {"llll"}));
      }
  
      public void testLastIndexOfAny() {
          assertEquals(-1, Strings.lastIndexOfAny(null, null));
          assertEquals(-1, Strings.lastIndexOfAny(null, FOOBAR_SUB_ARRAY));
          assertEquals(-1, Strings.lastIndexOfAny(FOOBAR, null));
          assertEquals(3, Strings.lastIndexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
          assertEquals(-1, Strings.lastIndexOfAny(FOOBAR, new String[0]));
          assertEquals(-1, Strings.lastIndexOfAny(FOOBAR, new String[] {"llll"}));
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsTrimEmptyTest.java
  
  Index: StringsTrimEmptyTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  /**
   * Unit tests {@link org.apache.commons.lang.Strings} - Trim/Empty methods
   *
   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
   * @version $Id: StringsTrimEmptyTest.java,v 1.1 2002/07/02 22:03:29 scolebourne Exp $
   */
  public class StringsTrimEmptyTest extends TestCase {
      private static final String FOO = "foo";
  
      public StringsTrimEmptyTest(String name) {
          super(name);
      }
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      public static TestSuite suite() {
          return new TestSuite(StringsTrimEmptyTest.class);
      }
  
      protected void setUp() throws Exception {
          super.setUp();
      }
  
      protected void tearDown() throws Exception {
          super.tearDown();
      }
  
      //-----------------------------------------------------------------------
  
      public void testClean() {
          assertEquals(FOO, Strings.clean(FOO + "  "));
          assertEquals(FOO, Strings.clean(" " + FOO + "  "));
          assertEquals(FOO, Strings.clean(" " + FOO));
          assertEquals(FOO, Strings.clean(FOO + ""));
          assertEquals("", Strings.clean(null));
      }
  
      public void testTrim() {
          assertEquals(FOO, Strings.trim(FOO + "  "));
          assertEquals(FOO, Strings.trim(" " + FOO + "  "));
          assertEquals(FOO, Strings.trim(" " + FOO));
          assertEquals(FOO, Strings.trim(FOO + ""));
          assertEquals(null, Strings.trim(null));
      }
  
      public void testIsNotEmpty() {
          assertEquals(true, Strings.isNotEmpty(FOO));
          assertEquals(true, Strings.isNotEmpty(" "));
          assertEquals(false, Strings.isNotEmpty(""));
          assertEquals(false, Strings.isNotEmpty(null));
      }
  
      public void testIsEmpty() {
          assertEquals(false, Strings.isEmpty(FOO));
          assertEquals(true, Strings.isEmpty(" "));
          assertEquals(true, Strings.isEmpty(""));
          assertEquals(true, Strings.isEmpty(null));
      }
  
  }
  
  
  

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