You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2002/07/09 23:06:43 UTC

cvs commit: jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang StringsIsTest.java

scolebourne    2002/07/09 14:06:43

  Added:       lang/src/test/org/apache/commons/lang StringsIsTest.java
  Log:
  Initial checkin of StringsIsTest
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/StringsIsTest.java
  
  Index: StringsIsTest.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;
  
  /**
   * Unit tests {@link org.apache.commons.lang.Strings} - Substring methods
   *
   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
   * @version $Id: StringsIsTest.java,v 1.1 2002/07/09 21:06:43 scolebourne Exp $
   */
  public class StringsIsTest extends TestCase {
  
      public StringsIsTest(String name) {
          super(name);
      }
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      public static Test suite() {
      	TestSuite suite = new TestSuite(StringsIsTest.class);
      	suite.setName("StringsIsXxx Tests");
          return suite;
      }
  
      protected void setUp() throws Exception {
          super.setUp();
      }
  
      protected void tearDown() throws Exception {
          super.tearDown();
      }
  
      //-----------------------------------------------------------------------
  
      public void testIsAlpha() {
          assertEquals(false, Strings.isAlpha(null));
          assertEquals(true, Strings.isAlpha(""));
          assertEquals(false, Strings.isAlpha(" "));
          assertEquals(true, Strings.isAlpha("a"));
          assertEquals(true, Strings.isAlpha("A"));
          assertEquals(true, Strings.isAlpha("kgKgKgKgkgkGkjkjlJlOKLgHdGdHgl"));
          assertEquals(false, Strings.isAlpha("ham kso"));
          assertEquals(false, Strings.isAlpha("1"));
          assertEquals(false, Strings.isAlpha("hkHKHik6iUGHKJgU7tUJgKJGI87GIkug"));
          assertEquals(false, Strings.isAlpha("_"));
          assertEquals(false, Strings.isAlpha("hkHKHik*khbkuh"));
      }
  
      public void testIsAlphanumeric() {
          assertEquals(false, Strings.isAlphanumeric(null));
          assertEquals(true, Strings.isAlphanumeric(""));
          assertEquals(false, Strings.isAlphanumeric(" "));
          assertEquals(true, Strings.isAlphanumeric("a"));
          assertEquals(true, Strings.isAlphanumeric("A"));
          assertEquals(true, Strings.isAlphanumeric("kgKgKgKgkgkGkjkjlJlOKLgHdGdHgl"));
          assertEquals(false, Strings.isAlphanumeric("ham kso"));
          assertEquals(true, Strings.isAlphanumeric("1"));
          assertEquals(true, Strings.isAlphanumeric("hkHKHik6iUGHKJgU7tUJgKJGI87GIkug"));
          assertEquals(false, Strings.isAlphanumeric("_"));
          assertEquals(false, Strings.isAlphanumeric("hkHKHik*khbkuh"));
      }
  
      public void testIsAlphaspace() {
          assertEquals(false, Strings.isAlphaSpace(null));
          assertEquals(true, Strings.isAlphaSpace(""));
          assertEquals(true, Strings.isAlphaSpace(" "));
          assertEquals(true, Strings.isAlphaSpace("a"));
          assertEquals(true, Strings.isAlphaSpace("A"));
          assertEquals(true, Strings.isAlphaSpace("kgKgKgKgkgkGkjkjlJlOKLgHdGdHgl"));
          assertEquals(true, Strings.isAlphaSpace("ham kso"));
          assertEquals(false, Strings.isAlphaSpace("1"));
          assertEquals(false, Strings.isAlphaSpace("hkHKHik6iUGHKJgU7tUJgKJGI87GIkug"));
          assertEquals(false, Strings.isAlphaSpace("_"));
          assertEquals(false, Strings.isAlphaSpace("hkHKHik*khbkuh"));
      }
  
      public void testIsAlphanumericSpace() {
          assertEquals(false, Strings.isAlphanumericSpace(null));
          assertEquals(true, Strings.isAlphanumericSpace(""));
          assertEquals(true, Strings.isAlphanumericSpace(" "));
          assertEquals(true, Strings.isAlphanumericSpace("a"));
          assertEquals(true, Strings.isAlphanumericSpace("A"));
          assertEquals(true, Strings.isAlphanumericSpace("kgKgKgKgkgkGkjkjlJlOKLgHdGdHgl"));
          assertEquals(true, Strings.isAlphanumericSpace("ham kso"));
          assertEquals(true, Strings.isAlphanumericSpace("1"));
          assertEquals(true, Strings.isAlphanumericSpace("hkHKHik6iUGHKJgU7tUJgKJGI87GIkug"));
          assertEquals(false, Strings.isAlphanumericSpace("_"));
          assertEquals(false, Strings.isAlphanumericSpace("hkHKHik*khbkuh"));
      }
  
      public void testIsNumeric() {
          assertEquals(false, Strings.isNumeric(null));
          assertEquals(true, Strings.isNumeric(""));
          assertEquals(false, Strings.isNumeric(" "));
          assertEquals(false, Strings.isNumeric("a"));
          assertEquals(false, Strings.isNumeric("A"));
          assertEquals(false, Strings.isNumeric("kgKgKgKgkgkGkjkjlJlOKLgHdGdHgl"));
          assertEquals(false, Strings.isNumeric("ham kso"));
          assertEquals(true, Strings.isNumeric("1"));
          assertEquals(true, Strings.isNumeric("1000"));
          assertEquals(false, Strings.isNumeric("2.3"));
          assertEquals(false, Strings.isNumeric("10 00"));
          assertEquals(false, Strings.isNumeric("hkHKHik6iUGHKJgU7tUJgKJGI87GIkug"));
          assertEquals(false, Strings.isNumeric("_"));
          assertEquals(false, Strings.isNumeric("hkHKHik*khbkuh"));
      }
  
      public void testIsNumericSpace() {
          assertEquals(false, Strings.isNumericSpace(null));
          assertEquals(true, Strings.isNumericSpace(""));
          assertEquals(true, Strings.isNumericSpace(" "));
          assertEquals(false, Strings.isNumericSpace("a"));
          assertEquals(false, Strings.isNumericSpace("A"));
          assertEquals(false, Strings.isNumericSpace("kgKgKgKgkgkGkjkjlJlOKLgHdGdHgl"));
          assertEquals(false, Strings.isNumericSpace("ham kso"));
          assertEquals(true, Strings.isNumericSpace("1"));
          assertEquals(true, Strings.isNumericSpace("1000"));
          assertEquals(false, Strings.isNumericSpace("2.3"));
          assertEquals(true, Strings.isNumericSpace("10 00"));
          assertEquals(false, Strings.isNumericSpace("hkHKHik6iUGHKJgU7tUJgKJGI87GIkug"));
          assertEquals(false, Strings.isNumericSpace("_"));
          assertEquals(false, Strings.isNumericSpace("hkHKHik*khbkuh"));
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>