commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [lang][patch] Unit tests for Strings.wrapText + Question
Date Wed, 10 Jul 2002 22:44:10 GMT
Patches applied, thanks.
(Apologies about the name/email mixup)

On the tab issue, I wouldn't expect calling a wrapping method to affect tabs
in any way. So I would favour leaving as is, rather than removing all tabs.

Stephen


----- Original Message -----
From: "Ringo De Smet" <ringods@yahoo.co.uk>
To: <commons-dev@jakarta.apache.org>
Sent: Wednesday, July 10, 2002 8:02 AM
Subject: [lang][patch] Unit tests for Strings.wrapText + Question


> Hello,
>
> The patch that you can find in attachment contains a new unit test
> class (StringsWrapTest). This class initially contains three test
> methods for the Strings.wrapText method. I added this new test class to
> the LangTestSuite. I also updated my name and email address in all the
> other test classes where it was placed by whom committed my previous
> patches.
>
> About Strings.wrapText: the JavaDoc mentions that TAB charachters will
> be removed from the output, but it is unclear if it will only remove
> TAB characters that are placed on the wrapping column index or remove
> all the tab characters from the input. The implementation does the
> former now. Was this the intention?
> I will update the JavaDoc and the unit tests when we have an agreement
> on this.
>
> Cheers,
>
> Ringo
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com


----------------------------------------------------------------------------
----


> Index: org/apache/commons/lang/CharSetTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/CharSetTest.java,v
> retrieving revision 1.2
> diff -u -r1.2 CharSetTest.java
> --- org/apache/commons/lang/CharSetTest.java 8 Jul 2002 21:48:30 -0000 1.2
> +++ org/apache/commons/lang/CharSetTest.java 10 Jul 2002 06:53:35 -0000
> @@ -64,7 +64,7 @@
>   * Unit tests {@link org.apache.commons.lang.CharSet}.
>   *
>   * @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: CharSetTest.java,v 1.2 2002/07/08 21:48:30 scolebourne
Exp $
>   */
>  public class CharSetTest extends TestCase
> Index: org/apache/commons/lang/LangTestSuite.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/LangTestSuite.java,v
> retrieving revision 1.4
> diff -u -r1.4 LangTestSuite.java
> --- org/apache/commons/lang/LangTestSuite.java 9 Jul 2002 21:06:26 -0000
1.4
> +++ org/apache/commons/lang/LangTestSuite.java 10 Jul 2002 06:53:28 -0000
> @@ -61,7 +61,7 @@
>   * Test suite for the Lang package.
>   *
>   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: LangTestSuite.java,v 1.4 2002/07/09 21:06:26 scolebourne
Exp $
>   */
>  public class LangTestSuite extends TestCase {
> @@ -97,6 +97,7 @@
>          suite.addTest(StringsSubstringTest.suite());
>          suite.addTest(StringsEqualsIndexOfTest.suite());
>          suite.addTest(StringsIsTest.suite());
> +        suite.addTest(StringsWrapTest.suite());
>          return suite;
>      }
>  }
> Index: org/apache/commons/lang/NumberRangeTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/NumberRangeTest.java,v
> retrieving revision 1.3
> diff -u -r1.3 NumberRangeTest.java
> --- org/apache/commons/lang/NumberRangeTest.java 8 Jul 2002 21:48:30 -0000
1.3
> +++ org/apache/commons/lang/NumberRangeTest.java 10 Jul 2002
06:53:29 -0000
> @@ -63,7 +63,7 @@
>   * Test cases for the {@link NumberRange} class.
>   *
>   * @author <a href="mailto:chrise@esha.com">Christopher Elkins</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Revision: 1.3 $ $Date: 2002/07/08 21:48:30 $
>   */
>
> Index: org/apache/commons/lang/NumbersTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/NumbersTest.java,v
> retrieving revision 1.5
> diff -u -r1.5 NumbersTest.java
> --- org/apache/commons/lang/NumbersTest.java 8 Jul 2002 22:07:37 -0000 1.5
> +++ org/apache/commons/lang/NumbersTest.java 10 Jul 2002 06:53:33 -0000
> @@ -65,7 +65,7 @@
>   * Unit tests {@link org.apache.commons.lang.Numbers}.
>   *
>   * @author <a href="mailto:rand_mcneely@yahoo.com">Rand McNeely</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: NumbersTest.java,v 1.5 2002/07/08 22:07:37 scolebourne
Exp $
>   */
>  public class NumbersTest extends TestCase {
> Index: org/apache/commons/lang/ObjectsTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/ObjectsTest.java,v
> retrieving revision 1.6
> diff -u -r1.6 ObjectsTest.java
> --- org/apache/commons/lang/ObjectsTest.java 8 Jul 2002 21:48:29 -0000 1.6
> +++ org/apache/commons/lang/ObjectsTest.java 10 Jul 2002 06:53:35 -0000
> @@ -63,7 +63,7 @@
>   *
>   * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
>   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: ObjectsTest.java,v 1.6 2002/07/08 21:48:29 scolebourne
Exp $
>   */
>  public class ObjectsTest extends TestCase
> Index: org/apache/commons/lang/RandomStringsTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/RandomStringsTest.java,v
> retrieving revision 1.2
> diff -u -r1.2 RandomStringsTest.java
> --- org/apache/commons/lang/RandomStringsTest.java 8 Jul 2002
21:48:30 -0000 1.2
> +++ org/apache/commons/lang/RandomStringsTest.java 10 Jul 2002
06:53:32 -0000
> @@ -60,7 +60,7 @@
>   * Unit tests {@link org.apache.commons.lang.RandomStrings}.
>   *
>   * @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: RandomStringsTest.java,v 1.2 2002/07/08 21:48:30
scolebourne Exp $
>   */
>  public class RandomStringsTest extends junit.framework.TestCase {
> Index: org/apache/commons/lang/SerializationTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/SerializationTest.java,v
> retrieving revision 1.3
> diff -u -r1.3 SerializationTest.java
> --- org/apache/commons/lang/SerializationTest.java 8 Jul 2002
21:48:30 -0000 1.3
> +++ org/apache/commons/lang/SerializationTest.java 10 Jul 2002
06:53:30 -0000
> @@ -69,7 +69,7 @@
>   * Unit tests {@link org.apache.commons.lang.Serialization}.
>   *
>   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id$
>   */
>  public class SerializationTest extends TestCase {
> Index: org/apache/commons/lang/StringsEqualsIndexOfTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/StringsEqualsIndexOfTest.java,v
> retrieving revision 1.2
> diff -u -r1.2 StringsEqualsIndexOfTest.java
> --- org/apache/commons/lang/StringsEqualsIndexOfTest.java 8 Jul 2002
21:48:30 -0000 1.2
> +++ org/apache/commons/lang/StringsEqualsIndexOfTest.java 10 Jul 2002
06:53:31 -0000
> @@ -62,7 +62,7 @@
>   * Unit tests {@link org.apache.commons.lang.Strings} - Substring methods
>   *
>   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: StringsEqualsIndexOfTest.java,v 1.2 2002/07/08 21:48:30
scolebourne Exp $
>   */
>  public class StringsEqualsIndexOfTest extends TestCase {
> Index: org/apache/commons/lang/StringsSubstringTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/StringsSubstringTest.java,v
> retrieving revision 1.3
> diff -u -r1.3 StringsSubstringTest.java
> --- org/apache/commons/lang/StringsSubstringTest.java 9 Jul 2002
07:39:16 -0000 1.3
> +++ org/apache/commons/lang/StringsSubstringTest.java 10 Jul 2002
06:53:31 -0000
> @@ -62,7 +62,7 @@
>   * Unit tests {@link org.apache.commons.lang.Strings} - Substring methods
>   *
>   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: StringsSubstringTest.java,v 1.3 2002/07/09 07:39:16
bayard Exp $
>   */
>  public class StringsSubstringTest extends TestCase {
> Index: org/apache/commons/lang/StringsTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/StringsTest.java,v
> retrieving revision 1.11
> diff -u -r1.11 StringsTest.java
> --- org/apache/commons/lang/StringsTest.java 9 Jul 2002 07:17:58 -0000
1.11
> +++ org/apache/commons/lang/StringsTest.java 10 Jul 2002 06:53:34 -0000
> @@ -66,7 +66,7 @@
>   * @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>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: StringsTest.java,v 1.11 2002/07/09 07:17:58 bayard Exp $
>   */
>  public class StringsTest extends TestCase
> Index: org/apache/commons/lang/StringsTrimEmptyTest.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/lang/src/test/org/apache/commons/lan
g/StringsTrimEmptyTest.java,v
> retrieving revision 1.3
> diff -u -r1.3 StringsTrimEmptyTest.java
> --- org/apache/commons/lang/StringsTrimEmptyTest.java 9 Jul 2002
07:31:18 -0000 1.3
> +++ org/apache/commons/lang/StringsTrimEmptyTest.java 10 Jul 2002
06:53:33 -0000
> @@ -62,7 +62,7 @@
>   * Unit tests {@link org.apache.commons.lang.Strings} - Trim/Empty
methods
>   *
>   * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
> - * @author <a href="mailto:ringo.desmet@mediagenix.com">Ringo Desmet</a>
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
>   * @version $Id: StringsTrimEmptyTest.java,v 1.3 2002/07/09 07:31:18
bayard Exp $
>   */
>  public class StringsTrimEmptyTest extends TestCase {
> Index: org/apache/commons/lang/StringsWrapTest.java
> ===================================================================
> RCS file: org/apache/commons/lang/StringsWrapTest.java
> diff -N org/apache/commons/lang/StringsWrapTest.java
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ org/apache/commons/lang/StringsWrapTest.java 10 Jul 2002
06:53:28 -0000
> @@ -0,0 +1,112 @@
> +package org.apache.commons.lang;
> +
> +/* ====================================================================
> + * 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/>.
> + */
> +
> +import junit.framework.Test;
> +import junit.framework.TestCase;
> +import junit.framework.TestSuite;
> +
> +/**
> + * Unit tests for the wrap methods of Strings.
> + *
> + * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De
Smet</a>
> + * @version $Id$
> + */
> +public class StringsWrapTest extends TestCase {
> +
> + public StringsWrapTest(String name) {
> + super(name);
> + }
> +
> + public static Test suite() {
> + TestSuite suite = new TestSuite(StringsWrapTest.class);
> + suite.setName("Strings Wrapping Tests");
> + return suite;
> + }
> +
> + /**
> + * Wrap text. This is the most general use.
> + */
> + public void testWrapText1() {
> + String input =
> + "Here is one line of text that is going to be wrapped after 20
columns.";
> + String expected =
> + "Here is one line of\ntext that is going\nto be wrapped after\n20
columns.";
> + assertEquals("", Strings.wrapText(input, "\n", 20), expected);
> + }
> +
> + /**
> + * Wrap text with a tab character in the middle of a string.
> + */
> + public void testWrapText2() {
> + String input =
> + "Here is\tone line of text that is going to be wrapped after 20
columns.";
> + String expected =
> + "Here is\tone line of\ntext that is going\nto be wrapped after\n20
columns.";
> + assertEquals("", Strings.wrapText(input, "\n", 20), expected);
> + }
> +
> + /**
> + * Wrap text with a tab character located at the wrapping column index.
> + */
> + public void testWrapText3() {
> + String input =
> + "Here is one line of\ttext that is going to be wrapped after 20
columns.";
> + String expected =
> + "Here is one line\nof\ttext that is\ngoing to be wrapped\nafter 20
columns.";
> + assertEquals("", Strings.wrapText(input, "\n", 20), expected);
> + }
> +
> +}
>
>


----------------------------------------------------------------------------
----


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


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