Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 74253 invoked from network); 13 Feb 2006 16:22:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Feb 2006 16:22:38 -0000 Received: (qmail 95572 invoked by uid 500); 13 Feb 2006 16:22:20 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 95469 invoked by uid 500); 13 Feb 2006 16:22:20 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 95431 invoked by uid 99); 13 Feb 2006 16:22:20 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2006 08:22:20 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 13 Feb 2006 08:22:18 -0800 Received: (qmail 73705 invoked by uid 65534); 13 Feb 2006 16:21:56 -0000 Message-ID: <20060213162155.73679.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r377408 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text: AllTests.java AnnotationTest.java StringCharacterIteratorTest.java Date: Mon, 13 Feb 2006 16:21:52 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: tellison Date: Mon Feb 13 08:21:49 2006 New Revision: 377408 URL: http://svn.apache.org/viewcvs?rev=377408&view=rev Log: Applying patch HARMONY-87 (Test cases for 'text' Classlib module) Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AnnotationTest.java incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/StringCharacterIteratorTest.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java?rev=377408&r1=377407&r2=377408&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java Mon Feb 13 08:21:49 2006 @@ -29,7 +29,9 @@ TestSuite suite = new TestSuite( "Test for org.apache.harmony.tests.java.text"); //$JUnit-BEGIN$ + suite.addTestSuite(StringCharacterIteratorTest.class); suite.addTestSuite(RuleBasedCollatorTest.class); + suite.addTestSuite(AnnotationTest.class); suite.addTestSuite(BreakIteratorTest.class); suite.addTestSuite(MessageFormatTest.class); suite.addTestSuite(ChoiceFormatTest.class); Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AnnotationTest.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AnnotationTest.java?rev=377408&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AnnotationTest.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AnnotationTest.java Mon Feb 13 08:21:49 2006 @@ -0,0 +1,50 @@ +/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.tests.java.text; + +import java.text.Annotation; + +import junit.framework.TestCase; + +public class AnnotationTest extends TestCase { + + /** + * @tests java.text.Annotation(Object) + */ + public void testAnnotation() { + assertNotNull(new Annotation(null)); + assertNotNull(new Annotation("value")); + } + + /** + * @tests java.text.Annotation.getValue() + */ + public void testGetValue() { + Annotation a = new Annotation(null); + assertNull(a.getValue()); + String s = "value"; + a = new Annotation(s); + assertEquals("value", a.getValue()); + } + + /** + * @tests java.text.Annotation.toString() + */ + public void testToString() { + assertNotNull(new Annotation(null).toString()); + assertNotNull(new Annotation("value").toString()); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/StringCharacterIteratorTest.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/StringCharacterIteratorTest.java?rev=377408&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/StringCharacterIteratorTest.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/StringCharacterIteratorTest.java Mon Feb 13 08:21:49 2006 @@ -0,0 +1,364 @@ +/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.tests.java.text; + +import java.text.CharacterIterator; +import java.text.StringCharacterIterator; + +import junit.framework.TestCase; + +public class StringCharacterIteratorTest extends TestCase { + + /** + * @tests java.text.StringCharacterIterator(java.lang.String) + */ + public void test_ConstructorLjava_lang_String() { + assertNotNull(new StringCharacterIterator("value")); + assertNotNull(new StringCharacterIterator("")); + try { + new StringCharacterIterator(null); + fail("Assert 0: no null pointer"); + } catch (NullPointerException e) { + // expected + } + } + + /** + * @tests java.text.StringCharacterIterator.StringCharacterIterator(String, + * int) + */ + public void test_ConstructorI() { + assertNotNull(new StringCharacterIterator("value", 0)); + assertNotNull(new StringCharacterIterator("value", "value".length())); + assertNotNull(new StringCharacterIterator("", 0)); + try { + new StringCharacterIterator(null, 0); + fail("Assert 0: no null pointer"); + } catch (NullPointerException e) { + // expected + } + + try { + new StringCharacterIterator("value", -1); + fail("Assert 1: no illegal argument"); + } catch (IllegalArgumentException e) { + // expected + } + + try { + new StringCharacterIterator("value", "value".length() + 1); + fail("Assert 2: no illegal argument"); + } catch (IllegalArgumentException e) { + // expected + } + } + + /** + * @tests java.text.StringCharacterIterator(String, int, int, int) + */ + public void test_ConstructorIII() { + assertNotNull(new StringCharacterIterator("value", 0, "value".length(), + 0)); + assertNotNull(new StringCharacterIterator("value", 0, "value".length(), + 1)); + assertNotNull(new StringCharacterIterator("", 0, 0, 0)); + + try { + new StringCharacterIterator(null, 0, 0, 0); + fail("no null pointer"); + } catch (NullPointerException e) { + // Expected + } + + try { + new StringCharacterIterator("value", -1, "value".length(), 0); + fail("no illegal argument: invalid begin"); + } catch (IllegalArgumentException e) { + // Expected + } + + try { + new StringCharacterIterator("value", 0, "value".length() + 1, 0); + fail("no illegal argument: invalid end"); + } catch (IllegalArgumentException e) { + // Expected + } + + try { + new StringCharacterIterator("value", 2, 1, 0); + fail("no illegal argument: start greater than end"); + } catch (IllegalArgumentException e) { + // Expected + } + + try { + new StringCharacterIterator("value", 2, 1, 2); + fail("no illegal argument: start greater than end"); + } catch (IllegalArgumentException e) { + // Expected + } + + try { + new StringCharacterIterator("value", 2, 4, 1); + fail("no illegal argument: location greater than start"); + } catch (IllegalArgumentException e) { + // Expected + } + + try { + new StringCharacterIterator("value", 0, 2, 3); + fail("no illegal argument: location greater than start"); + } catch (IllegalArgumentException e) { + // Expected + } + } + + /** + * @tests java.text.StringCharacterIterator.equals(Object) + */ + public void test_equalsLjava_lang_Object() { + StringCharacterIterator sci0 = new StringCharacterIterator("fixture"); + assertEquals(sci0, sci0); + assertFalse(sci0.equals(null)); + assertFalse(sci0.equals("fixture")); + + StringCharacterIterator sci1 = new StringCharacterIterator("fixture"); + assertEquals(sci0, sci1); + + sci1.next(); + assertFalse(sci0.equals(sci1)); + sci0.next(); + assertEquals(sci0, sci1); + } + + /** + * @tests java.text.StringCharacterIterator.hashCode() + */ + public void test_hashCode() { + StringCharacterIterator sci0 = new StringCharacterIterator("fixture"); + assertEquals(sci0.hashCode(), sci0.hashCode()); + + StringCharacterIterator sci1 = new StringCharacterIterator("fixture"); + assertEquals(sci0.hashCode(), sci1.hashCode()); + + sci1.next(); + sci0.next(); + assertEquals(sci0.hashCode(), sci1.hashCode()); + } + + /** + * @tests java.text.StringCharacterIterator.clone() + */ + public void test_clone() { + StringCharacterIterator sci0 = new StringCharacterIterator("fixture"); + assertSame(sci0, sci0); + StringCharacterIterator sci1 = (StringCharacterIterator) sci0.clone(); + assertNotSame(sci0, sci1); + assertEquals(sci0, sci1); + } + + /** + * @tests java.text.StringCharacterIterator.current() + */ + public void test_current() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals('f', fixture.current()); + fixture.next(); + assertEquals('i', fixture.current()); + } + + /** + * @tests java.text.StringCharacterIterator.first() + */ + public void test_first() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals('f', fixture.first()); + fixture.next(); + assertEquals('f', fixture.first()); + fixture = new StringCharacterIterator("fixture", 1); + assertEquals('f', fixture.first()); + fixture = new StringCharacterIterator("fixture", 1, "fixture".length(), + 2); + assertEquals('i', fixture.first()); + } + + /** + * @tests java.text.StringCharacterIterator.getBeginIndex() + */ + public void test_getBeginIndex() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals(0, fixture.getBeginIndex()); + fixture = new StringCharacterIterator("fixture", 1); + assertEquals(0, fixture.getBeginIndex()); + fixture = new StringCharacterIterator("fixture", 1, "fixture".length(), + 2); + assertEquals(1, fixture.getBeginIndex()); + } + + /** + * @tests java.text.StringCharacterIterator.getEndIndex() + */ + public void test_getEndIndex() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals("fixture".length(), fixture.getEndIndex()); + fixture = new StringCharacterIterator("fixture", 1); + assertEquals("fixture".length(), fixture.getEndIndex()); + fixture = new StringCharacterIterator("fixture", 1, "fixture".length(), + 2); + assertEquals("fixture".length(), fixture.getEndIndex()); + fixture = new StringCharacterIterator("fixture", 1, 4, 2); + assertEquals(4, fixture.getEndIndex()); + } + + /** + * @tests java.text.StringCharacterIterator.getIndex() + */ + public void testGetIndex() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals(0, fixture.getIndex()); + fixture = new StringCharacterIterator("fixture", 1); + assertEquals(1, fixture.getIndex()); + fixture = new StringCharacterIterator("fixture", 1, "fixture".length(), + 2); + assertEquals(2, fixture.getIndex()); + fixture = new StringCharacterIterator("fixture", 1, 4, 2); + assertEquals(2, fixture.getIndex()); + } + + /** + * @tests java.text.StringCharacterIterator.last() + */ + public void testLast() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals('e', fixture.last()); + fixture.next(); + assertEquals('e', fixture.last()); + fixture = new StringCharacterIterator("fixture", 1); + assertEquals('e', fixture.last()); + fixture = new StringCharacterIterator("fixture", 1, "fixture".length(), + 2); + assertEquals('e', fixture.last()); + fixture = new StringCharacterIterator("fixture", 1, 4, 2); + assertEquals('t', fixture.last()); + } + + /** + * @tests java.text.StringCharacterIterator.next() + */ + public void test_next() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals(0, fixture.getIndex()); + assertEquals('i', fixture.next()); + assertEquals(1, fixture.getIndex()); + assertEquals('x', fixture.next()); + assertEquals(2, fixture.getIndex()); + assertEquals('t', fixture.next()); + assertEquals(3, fixture.getIndex()); + assertEquals('u', fixture.next()); + assertEquals(4, fixture.getIndex()); + assertEquals('r', fixture.next()); + assertEquals(5, fixture.getIndex()); + assertEquals('e', fixture.next()); + assertEquals(6, fixture.getIndex()); + assertEquals(CharacterIterator.DONE, fixture.next()); + assertEquals(7, fixture.getIndex()); + assertEquals(CharacterIterator.DONE, fixture.next()); + assertEquals(7, fixture.getIndex()); + assertEquals(CharacterIterator.DONE, fixture.next()); + assertEquals(7, fixture.getIndex()); + } + + /** + * @tests java.text.StringCharacterIterator.previous() + */ + public void test_previous() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + assertEquals(CharacterIterator.DONE, fixture.previous()); + assertEquals('i', fixture.next()); + assertEquals('x', fixture.next()); + assertEquals('t', fixture.next()); + assertEquals('u', fixture.next()); + assertEquals('r', fixture.next()); + assertEquals('e', fixture.next()); + assertEquals(CharacterIterator.DONE, fixture.next()); + assertEquals(CharacterIterator.DONE, fixture.next()); + assertEquals(CharacterIterator.DONE, fixture.next()); + assertEquals(7, fixture.getIndex()); + assertEquals('e', fixture.previous()); + assertEquals(6, fixture.getIndex()); + assertEquals('r', fixture.previous()); + assertEquals(5, fixture.getIndex()); + assertEquals('u', fixture.previous()); + assertEquals(4, fixture.getIndex()); + assertEquals('t', fixture.previous()); + assertEquals(3, fixture.getIndex()); + assertEquals('x', fixture.previous()); + assertEquals(2, fixture.getIndex()); + assertEquals('i', fixture.previous()); + assertEquals(1, fixture.getIndex()); + assertEquals('f', fixture.previous()); + assertEquals(0, fixture.getIndex()); + assertEquals(CharacterIterator.DONE, fixture.previous()); + assertEquals(0, fixture.getIndex()); + } + + /** + * @tests java.text.StringCharacterIterator.setIndex(int) + */ + public void test_setIndex() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + while (fixture.next() != CharacterIterator.DONE) { + // empty + } + assertEquals("fixture".length(), fixture.getIndex()); + fixture.setIndex(0); + assertEquals(0, fixture.getIndex()); + assertEquals('f', fixture.current()); + fixture.setIndex("fixture".length() - 1); + assertEquals('e', fixture.current()); + try { + fixture.setIndex(-1); + fail("no illegal argument"); + } catch (IllegalArgumentException e) { + // expected + } + + try { + fixture.setIndex("fixture".length() + 1); + fail("no illegal argument"); + } catch (IllegalArgumentException e) { + // expected + } + } + + /** + * @tests java.text.StringCharacterIterator.setText(String) + */ + public void test_setText() { + StringCharacterIterator fixture = new StringCharacterIterator("fixture"); + fixture.setText("fix"); + assertEquals('f', fixture.current()); + assertEquals('x', fixture.last()); + + try { + fixture.setText(null); + fail("no null pointer"); + } catch (NullPointerException e) { + // expected + } + } + +}