harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r429091 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test: api/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java java/tests/api/java/lang/AllTests.java java/tests/api/java/lang/CharacterTest.java
Date Sun, 06 Aug 2006 01:53:20 GMT
Author: ndbeyer
Date: Sat Aug  5 18:53:19 2006
New Revision: 429091

URL: http://svn.apache.org/viewvc?rev=429091&view=rev
Log:
Consolidate CharacterTest classes.

Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java?rev=429091&r1=429090&r2=429091&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
Sat Aug  5 18:53:19 2006
@@ -628,4 +628,469 @@
             fail("Expected IndexOutOfBoundsException");
         }
     }
+    
+    /**
+     * @tests java.lang.Character#Character(char)
+     */
+    public void test_ConstructorC() {
+        // Test for method java.lang.Character(char)
+        assertEquals("Constructor failed", 'T', new Character('T').charValue());
+    }
+
+    /**
+     * @tests java.lang.Character#charValue()
+     */
+    public void test_charValue() {
+        // Test for method char java.lang.Character.charValue()
+        assertEquals("Incorrect char value returned", 'T', new Character('T')
+                .charValue());
+    }
+
+    /**
+     * @tests java.lang.Character#compareTo(java.lang.Character)
+     */
+    public void test_compareToLjava_lang_Character() {
+        // Test for method int
+        // java.lang.Character.compareTo(java.lang.Character)
+        Character c = new Character('c');
+        Character x = new Character('c');
+        Character y = new Character('b');
+        Character z = new Character('d');
+
+        assertEquals("Returned false for same Character", 0, c.compareTo(c));
+        assertEquals("Returned false for identical Character",
+                0, c.compareTo(x));
+        assertTrue("Returned other than less than for lesser char", c
+                .compareTo(y) > 0);
+        assertTrue("Returned other than greater than for greater char", c
+                .compareTo(z) < 0);
+    }
+
+    /**
+     * @tests java.lang.Character#digit(char, int)
+     */
+    public void test_digitCI() {
+        // Test for method int java.lang.Character.digit(char, int)
+        assertEquals("Returned incorrect digit", 1, Character.digit('1', 10));
+        assertEquals("Returned incorrect digit", 15, Character.digit('F', 16));
+    }
+
+    /**
+     * @tests java.lang.Character#equals(java.lang.Object)
+     */
+    public void test_equalsLjava_lang_Object() {
+        // Test for method boolean java.lang.Character.equals(java.lang.Object)
+        assertTrue("Equality test failed", new Character('A')
+                .equals(new Character('A')));
+        assertTrue("Equality test failed", !(new Character('A')
+                .equals(new Character('a'))));
+    }
+
+    /**
+     * @tests java.lang.Character#forDigit(int, int)
+     */
+    public void test_forDigitII() {
+        // Test for method char java.lang.Character.forDigit(int, int)
+
+        char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+                'a', 'b', 'c', 'd', 'e', 'f' };
+        for (int i = 0; i < hexChars.length; i++) {
+            assertTrue("Returned incorrect char for " + Integer.toString(i),
+                    Character.forDigit(i, hexChars.length) == hexChars[i]);
+        }
+
+        char decimalChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
+                '9' };
+        for (int i = 0; i < decimalChars.length; i++) {
+            assertTrue(
+                    "Returned incorrect char for " + Integer.toString(i),
+                    Character.forDigit(i, decimalChars.length) == decimalChars[i]);
+        }
+
+    }
+
+    /**
+     * @tests java.lang.Character#getNumericValue(char)
+     */
+    public void test_getNumericValueC() {
+        // Test for method int java.lang.Character.getNumericValue(char)
+        assertEquals("Returned incorrect numeric value 1", 1, Character
+                .getNumericValue('1'));
+        assertEquals("Returned incorrect numeric value 2", 15, Character
+                .getNumericValue('F'));
+        assertEquals("Returned incorrect numeric value 3", -1, Character
+                .getNumericValue('\u221e'));
+        assertEquals("Returned incorrect numeric value 4", -2, Character
+                .getNumericValue('\u00be'));
+        assertEquals("Returned incorrect numeric value 5", 10000, Character
+                .getNumericValue('\u2182'));
+        assertEquals("Returned incorrect numeric value 6", 2, Character
+                .getNumericValue('\uff12'));
+    }
+
+    /**
+     * @tests java.lang.Character#getType(char)
+     */
+    public void test_getTypeC() {
+        // Test for method int java.lang.Character.getType(char)
+        assertTrue("Returned incorrect type for: \n",
+                Character.getType('\n') == Character.CONTROL);
+        assertTrue("Returned incorrect type for: 1",
+                Character.getType('1') == Character.DECIMAL_DIGIT_NUMBER);
+        assertTrue("Returned incorrect type for: ' '",
+                Character.getType(' ') == Character.SPACE_SEPARATOR);
+        assertTrue("Returned incorrect type for: a",
+                Character.getType('a') == Character.LOWERCASE_LETTER);
+        assertTrue("Returned incorrect type for: A",
+                Character.getType('A') == Character.UPPERCASE_LETTER);
+        assertTrue("Returned incorrect type for: <",
+                Character.getType('<') == Character.MATH_SYMBOL);
+        assertTrue("Returned incorrect type for: ;",
+                Character.getType(';') == Character.OTHER_PUNCTUATION);
+        assertTrue("Returned incorrect type for: _",
+                Character.getType('_') == Character.CONNECTOR_PUNCTUATION);
+        assertTrue("Returned incorrect type for: $",
+                Character.getType('$') == Character.CURRENCY_SYMBOL);
+        assertTrue("Returned incorrect type for: \u2029", Character
+                .getType('\u2029') == Character.PARAGRAPH_SEPARATOR);
+
+        assertEquals("Wrong constant for FORMAT", 16, Character.FORMAT);
+        assertEquals("Wrong constant for PRIVATE_USE",
+                18, Character.PRIVATE_USE);
+    }
+
+    /**
+     * @tests java.lang.Character#hashCode()
+     */
+    public void test_hashCode() {
+        // Test for method int java.lang.Character.hashCode()
+        assertEquals("Incorrect hash returned",
+                89, new Character('Y').hashCode());
+    }
+
+    /**
+     * @tests java.lang.Character#isDefined(char)
+     */
+    public void test_isDefinedC() {
+        // Test for method boolean java.lang.Character.isDefined(char)
+        assertTrue("Defined character returned false", Character.isDefined('v'));
+        assertTrue("Undefined character returned true", Character
+                .isDefined('\u6039'));
+    }
+
+    /**
+     * @tests java.lang.Character#isDigit(char)
+     */
+    public void test_isDigitC() {
+        // Test for method boolean java.lang.Character.isDigit(char)
+        assertTrue("Digit returned false", Character.isDigit('1'));
+        assertTrue("Non-Digit returned false", !Character.isDigit('A'));
+    }
+
+    /**
+     * @tests java.lang.Character#isIdentifierIgnorable(char)
+     */
+    public void test_isIdentifierIgnorableC() {
+        // Test for method boolean
+        // java.lang.Character.isIdentifierIgnorable(char)
+        assertTrue("Ignorable whitespace returned false", Character
+                .isIdentifierIgnorable('\u0007'));
+        assertTrue("Ignorable non - whitespace  control returned false",
+                Character.isIdentifierIgnorable('\u000f'));
+        assertTrue("Ignorable join control returned false", Character
+                .isIdentifierIgnorable('\u200e'));
+
+        // the spec is wrong, and our implementation is correct
+        assertTrue("Ignorable bidi control returned false", Character
+                .isIdentifierIgnorable('\u202b'));
+
+        assertTrue("Ignorable format control returned false", Character
+                .isIdentifierIgnorable('\u206c'));
+        assertTrue("Ignorable zero-width no-break returned false", Character
+                .isIdentifierIgnorable('\ufeff'));
+
+        assertTrue("Non-Ignorable returned true", !Character
+                .isIdentifierIgnorable('\u0065'));
+    }
+
+    /**
+     * @tests java.lang.Character#isISOControl(char)
+     */
+    public void test_isISOControlC() {
+        // Test for method boolean java.lang.Character.isISOControl(char)
+        for (int i = 0; i < 32; i++)
+            assertTrue("ISOConstrol char returned false", Character
+                    .isISOControl((char) i));
+
+        for (int i = 127; i < 160; i++)
+            assertTrue("ISOConstrol char returned false", Character
+                    .isISOControl((char) i));
+    }
+
+    /**
+     * @tests java.lang.Character#isISOControl(int)
+     */
+    public void test_isISOControlI() {
+        // Test for method boolean java.lang.Character.isISOControl(char)
+        for (int i = 0; i < 32; i++)
+            assertTrue("ISOConstrol char returned false", Character
+                .isISOControl(i));
+
+        for (int i = 127; i < 160; i++)
+            assertTrue("ISOConstrol char returned false", Character
+                .isISOControl(i));
+
+        for (int i = 160; i < 260; i++)
+            assertFalse("Not ISOConstrol char returned true", Character
+                .isISOControl(i));
+
+    }
+
+
+    /**
+     * @tests java.lang.Character#isJavaIdentifierPart(char)
+     */
+    public void test_isJavaIdentifierPartC() {
+        // Test for method boolean
+        // java.lang.Character.isJavaIdentifierPart(char)
+        assertTrue("letter returned false", Character.isJavaIdentifierPart('l'));
+        assertTrue("currency returned false", Character
+                .isJavaIdentifierPart('$'));
+        assertTrue("digit returned false", Character.isJavaIdentifierPart('9'));
+        assertTrue("connecting char returned false", Character
+                .isJavaIdentifierPart('_'));
+        assertTrue("ignorable control returned true", !Character
+                .isJavaIdentifierPart('\u200b'));
+        assertTrue("semi returned true", !Character.isJavaIdentifierPart(';'));
+    }
+
+    /**
+     * @tests java.lang.Character#isJavaIdentifierStart(char)
+     */
+    public void test_isJavaIdentifierStartC() {
+        // Test for method boolean
+        // java.lang.Character.isJavaIdentifierStart(char)
+        assertTrue("letter returned false", Character
+                .isJavaIdentifierStart('l'));
+        assertTrue("currency returned false", Character
+                .isJavaIdentifierStart('$'));
+        assertTrue("connecting char returned false", Character
+                .isJavaIdentifierStart('_'));
+        assertTrue("digit returned true", !Character.isJavaIdentifierStart('9'));
+        assertTrue("ignorable control returned true", !Character
+                .isJavaIdentifierStart('\u200b'));
+        assertTrue("semi returned true", !Character.isJavaIdentifierStart(';'));
+    }
+
+    /**
+     * @tests java.lang.Character#isJavaLetter(char)
+     */
+    public void test_isJavaLetterC() {
+        // Test for method boolean java.lang.Character.isJavaLetter(char)
+        assertTrue("letter returned false", Character.isJavaLetter('l'));
+        assertTrue("currency returned false", Character.isJavaLetter('$'));
+        assertTrue("connecting char returned false", Character
+                .isJavaLetter('_'));
+
+        assertTrue("digit returned true", !Character.isJavaLetter('9'));
+        assertTrue("ignirable control returned true", !Character
+                .isJavaLetter('\u200b'));
+        assertTrue("semi returned true", !Character.isJavaLetter(';'));
+    }
+
+    /**
+     * @tests java.lang.Character#isJavaLetterOrDigit(char)
+     */
+    public void test_isJavaLetterOrDigitC() {
+        // Test for method boolean java.lang.Character.isJavaLetterOrDigit(char)
+        assertTrue("letter returned false", Character.isJavaLetterOrDigit('l'));
+        assertTrue("currency returned false", Character
+                .isJavaLetterOrDigit('$'));
+        assertTrue("digit returned false", Character.isJavaLetterOrDigit('9'));
+        assertTrue("connecting char returned false", Character
+                .isJavaLetterOrDigit('_'));
+        assertTrue("semi returned true", !Character.isJavaLetterOrDigit(';'));
+    }
+
+    /**
+     * @tests java.lang.Character#isLetter(char)
+     */
+    public void test_isLetterC() {
+        // Test for method boolean java.lang.Character.isLetter(char)
+        assertTrue("Letter returned false", Character.isLetter('L'));
+        assertTrue("Non-Letter returned true", !Character.isLetter('9'));
+    }
+
+    /**
+     * @tests java.lang.Character#isLetterOrDigit(char)
+     */
+    public void test_isLetterOrDigitC() {
+        // Test for method boolean java.lang.Character.isLetterOrDigit(char)
+        assertTrue("Digit returned false", Character.isLetterOrDigit('9'));
+        assertTrue("Letter returned false", Character.isLetterOrDigit('K'));
+        assertTrue("Control returned true", !Character.isLetterOrDigit('\n'));
+        assertTrue("Puncutation returned true", !Character.isLetterOrDigit('?'));
+    }
+
+    /**
+     * @tests java.lang.Character#isLowerCase(char)
+     */
+    public void test_isLowerCaseC() {
+        // Test for method boolean java.lang.Character.isLowerCase(char)
+        assertTrue("lower returned false", Character.isLowerCase('a'));
+        assertTrue("upper returned true", !Character.isLowerCase('T'));
+    }
+
+    /**
+     * @tests java.lang.Character#isSpace(char)
+     */
+    public void test_isSpaceC() {
+        // Test for method boolean java.lang.Character.isSpace(char)
+        assertTrue("space returned false", Character.isSpace('\n'));
+        assertTrue("non-space returned true", !Character.isSpace('T'));
+    }
+
+    /**
+     * @tests java.lang.Character#isSpaceChar(char)
+     */
+    public void test_isSpaceCharC() {
+        // Test for method boolean java.lang.Character.isSpaceChar(char)
+        assertTrue("space returned false", Character.isSpaceChar('\u0020'));
+        assertTrue("non-space returned true", !Character.isSpaceChar('\n'));
+    }
+
+    /**
+     * @tests java.lang.Character#isTitleCase(char)
+     */
+    public void test_isTitleCaseC() {
+        // Test for method boolean java.lang.Character.isTitleCase(char)
+
+        char[] tChars = { (char) 0x01c5, (char) 0x01c8, (char) 0x01cb,
+                (char) 0x01f2, (char) 0x1f88, (char) 0x1f89, (char) 0x1f8a,
+                (char) 0x1f8b, (char) 0x1f8c, (char) 0x1f8d, (char) 0x1f8e,
+                (char) 0x1f8f, (char) 0x1f98, (char) 0x1f99, (char) 0x1f9a,
+                (char) 0x1f9b, (char) 0x1f9c, (char) 0x1f9d, (char) 0x1f9e,
+                (char) 0x1f9f, (char) 0x1fa8, (char) 0x1fa9, (char) 0x1faa,
+                (char) 0x1fab, (char) 0x1fac, (char) 0x1fad, (char) 0x1fae,
+                (char) 0x1faf, (char) 0x1fbc, (char) 0x1fcc, (char) 0x1ffc };
+        byte tnum = 0;
+        for (char c = 0; c < 65535; c++) {
+            if (Character.isTitleCase(c)) {
+                tnum++;
+                int i;
+                for (i = 0; i < tChars.length; i++)
+                    if (tChars[i] == c)
+                        i = tChars.length + 1;
+                if (i < tChars.length) {
+                    fail("Non Title Case char returned true");
+                }
+            }
+        }
+        assertTrue("Failed to find all Title Case chars", tnum == tChars.length);
+    }
+
+    /**
+     * @tests java.lang.Character#isUnicodeIdentifierPart(char)
+     */
+    public void test_isUnicodeIdentifierPartC() {
+        // Test for method boolean
+        // java.lang.Character.isUnicodeIdentifierPart(char)
+        assertTrue("'a' returned false", Character.isUnicodeIdentifierPart('a'));
+        assertTrue("'2' returned false", Character.isUnicodeIdentifierPart('2'));
+        assertTrue("'+' returned true", !Character.isUnicodeIdentifierPart('+'));
+    }
+
+    /**
+     * @tests java.lang.Character#isUnicodeIdentifierStart(char)
+     */
+    public void test_isUnicodeIdentifierStartC() {
+        // Test for method boolean
+        // java.lang.Character.isUnicodeIdentifierStart(char)
+        assertTrue("'a' returned false", Character
+                .isUnicodeIdentifierStart('a'));
+        assertTrue("'2' returned true", !Character
+                .isUnicodeIdentifierStart('2'));
+        assertTrue("'+' returned true", !Character
+                .isUnicodeIdentifierStart('+'));
+    }
+
+    /**
+     * @tests java.lang.Character#isUpperCase(char)
+     */
+    public void test_isUpperCaseC() {
+        // Test for method boolean java.lang.Character.isUpperCase(char)
+        assertTrue("Incorrect case value", !Character.isUpperCase('t'));
+        assertTrue("Incorrect case value", Character.isUpperCase('T'));
+    }
+
+    /**
+     * @tests java.lang.Character#isWhitespace(char)
+     */
+    public void test_isWhitespaceC() {
+        // Test for method boolean java.lang.Character.isWhitespace(char)
+        assertTrue("space returned false", Character.isWhitespace('\n'));
+        assertTrue("non-space returned true", !Character.isWhitespace('T'));
+    }
+
+    /**
+     * @tests java.lang.Character#reverseBytes(char)
+     */
+    public void test_reverseBytesC() {
+        char original[] = new char[]{0x0000, 0x0010, 0x00AA, 0xB000, 0xCC00, 0xABCD, 0xFFAA};
+        char reversed[] = new char[]{0x0000, 0x1000, 0xAA00, 0x00B0, 0x00CC, 0xCDAB, 0xAAFF};
+        assertTrue("Test self check", original.length==reversed.length);
+
+        for (int i=0; i<original.length; i++) {
+            char origChar = original[i];
+            char reversedChar = reversed[i];
+            char origReversed= Character.reverseBytes(origChar);
+
+            assertTrue("java.lang.Character.reverseBytes failed: orig char="
+                +Integer.toHexString(origChar)+", reversed char="
+                +Integer.toHexString(origReversed), reversedChar==origReversed);
+        }
+    }
+
+    /**
+     * @tests java.lang.Character#toLowerCase(char)
+     */
+    public void test_toLowerCaseC() {
+        // Test for method char java.lang.Character.toLowerCase(char)
+        assertEquals("Failed to change case", 't', Character.toLowerCase('T'));
+    }
+
+    /**
+     * @tests java.lang.Character#toString()
+     */
+    public void test_toString() {
+        // Test for method java.lang.String java.lang.Character.toString()
+        assertEquals("Incorrect String returned", "T", new Character('T').toString()
+                );
+    }
+
+    /**
+     * @tests java.lang.Character#toTitleCase(char)
+     */
+    public void test_toTitleCaseC() {
+        // Test for method char java.lang.Character.toTitleCase(char)
+        assertEquals("Incorrect title case for a",
+                'A', Character.toTitleCase('a'));
+        assertEquals("Incorrect title case for A",
+                'A', Character.toTitleCase('A'));
+        assertEquals("Incorrect title case for 1",
+                '1', Character.toTitleCase('1'));
+    }
+
+    /**
+     * @tests java.lang.Character#toUpperCase(char)
+     */
+    public void test_toUpperCaseC() {
+        // Test for method char java.lang.Character.toUpperCase(char)
+        assertEquals("Incorrect upper case for a",
+                'A', Character.toUpperCase('a'));
+        assertEquals("Incorrect upper case for A",
+                'A', Character.toUpperCase('A'));
+        assertEquals("Incorrect upper case for 1",
+                '1', Character.toUpperCase('1'));
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java?rev=429091&r1=429090&r2=429091&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
Sat Aug  5 18:53:19 2006
@@ -15,6 +15,8 @@
 
 package tests.api.java.lang;
 
+import org.apache.harmony.luni.tests.java.lang.BooleanTest;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -32,7 +34,7 @@
 
 		suite.addTestSuite(BooleanTest.class);
 		suite.addTestSuite(ByteTest.class);
-		suite.addTestSuite(CharacterTest.class);
+
 		suite.addTestSuite(ClassTest.class);
 		suite.addTestSuite(ClassLoaderTest.class);
 		suite.addTestSuite(CompilerTest.class);



Mime
View raw message