Source Code Cross Referenced for CharacterTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » luni » tests » java » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.luni.tests.java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* Licensed to the Apache Software Foundation (ASF) under one or more
0002:         * contributor license agreements.  See the NOTICE file distributed with
0003:         * this work for additional information regarding copyright ownership.
0004:         * The ASF licenses this file to You under the Apache License, Version 2.0
0005:         * (the "License"); you may not use this file except in compliance with
0006:         * the License.  You may obtain a copy of the License at
0007:         * 
0008:         *     http://www.apache.org/licenses/LICENSE-2.0
0009:         * 
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.
0015:         */
0016:
0017:        package org.apache.harmony.luni.tests.java.lang;
0018:
0019:        import java.util.Arrays;
0020:
0021:        import junit.framework.TestCase;
0022:
0023:        public class CharacterTest extends TestCase {
0024:
0025:            public void test_valueOfC() {
0026:                // test the cache range
0027:                for (char c = '\u0000'; c < 512; c++) {
0028:                    Character e = new Character(c);
0029:                    Character a = Character.valueOf(c);
0030:                    assertEquals(e, a);
0031:                }
0032:                // test the rest of the chars
0033:                for (int c = 512; c <= Character.MAX_VALUE; c++) {
0034:                    assertEquals(new Character((char) c), Character
0035:                            .valueOf((char) c));
0036:                }
0037:            }
0038:
0039:            public void test_isValidCodePointI() {
0040:                assertFalse(Character.isValidCodePoint(-1));
0041:                assertTrue(Character.isValidCodePoint(0));
0042:                assertTrue(Character.isValidCodePoint(1));
0043:                assertFalse(Character.isValidCodePoint(Integer.MAX_VALUE));
0044:
0045:                for (int c = '\u0000'; c <= 0x10FFFF; c++) {
0046:                    assertTrue(Character.isValidCodePoint(c));
0047:                }
0048:
0049:                assertFalse(Character.isValidCodePoint(0x10FFFF + 1));
0050:            }
0051:
0052:            public void test_isSupplementaryCodePointI() {
0053:                assertFalse(Character.isSupplementaryCodePoint(-1));
0054:
0055:                for (int c = '\u0000'; c <= '\uFFFF'; c++) {
0056:                    assertFalse(Character.isSupplementaryCodePoint(c));
0057:                }
0058:
0059:                for (int c = 0xFFFF + 1; c <= 0x10FFFF; c++) {
0060:                    assertTrue(Character.isSupplementaryCodePoint(c));
0061:                }
0062:
0063:                assertFalse(Character.isSupplementaryCodePoint(0x10FFFF + 1));
0064:            }
0065:
0066:            public void test_isHighSurrogateC() {
0067:                // (\uD800-\uDBFF)
0068:                assertFalse(Character.isHighSurrogate((char) ('\uD800' - 1)));
0069:                for (int c = '\uD800'; c <= '\uDBFF'; c++) {
0070:                    assertTrue(Character.isHighSurrogate((char) c));
0071:                }
0072:                assertFalse(Character.isHighSurrogate((char) ('\uDBFF' + 1)));
0073:                assertFalse(Character.isHighSurrogate('\uFFFF'));
0074:            }
0075:
0076:            public void test_isLowSurrogateC() {
0077:                // (\uDC00-\uDFFF)
0078:                assertFalse(Character.isLowSurrogate((char) ('\uDC00' - 1)));
0079:                for (int c = '\uDC00'; c <= '\uDFFF'; c++) {
0080:                    assertTrue(Character.isLowSurrogate((char) c));
0081:                }
0082:                assertFalse(Character.isLowSurrogate((char) ('\uDFFF' + 1)));
0083:            }
0084:
0085:            public void test_isSurrogatePairCC() {
0086:                assertFalse(Character.isSurrogatePair('\u0000', '\u0000'));
0087:                assertFalse(Character.isSurrogatePair('\u0000', '\uDC00'));
0088:
0089:                assertTrue(Character.isSurrogatePair('\uD800', '\uDC00'));
0090:                assertTrue(Character.isSurrogatePair('\uD800', '\uDFFF'));
0091:                assertTrue(Character.isSurrogatePair('\uDBFF', '\uDFFF'));
0092:
0093:                assertFalse(Character.isSurrogatePair('\uDBFF', '\uF000'));
0094:            }
0095:
0096:            public void test_charCountI() {
0097:
0098:                for (int c = '\u0000'; c <= '\uFFFF'; c++) {
0099:                    assertEquals(1, Character.charCount(c));
0100:                }
0101:
0102:                for (int c = 0xFFFF + 1; c <= 0x10FFFF; c++) {
0103:                    assertEquals(2, Character.charCount(c));
0104:                }
0105:
0106:                // invalid code points work in this method
0107:                assertEquals(2, Character.charCount(Integer.MAX_VALUE));
0108:            }
0109:
0110:            public void test_toCodePointCC() {
0111:                int result = Character.toCodePoint('\uD800', '\uDC00');
0112:                assertEquals(0x00010000, result);
0113:
0114:                result = Character.toCodePoint('\uD800', '\uDC01');
0115:                assertEquals(0x00010001, result);
0116:
0117:                result = Character.toCodePoint('\uD801', '\uDC01');
0118:                assertEquals(0x00010401, result);
0119:
0120:                result = Character.toCodePoint('\uDBFF', '\uDFFF');
0121:                assertEquals(0x00010FFFF, result);
0122:            }
0123:
0124:            @SuppressWarnings("cast")
0125:            public void test_codePointAtLjava_lang_CharSequenceI() {
0126:
0127:                assertEquals('a', Character
0128:                        .codePointAt((CharSequence) "abc", 0));
0129:                assertEquals('b', Character
0130:                        .codePointAt((CharSequence) "abc", 1));
0131:                assertEquals('c', Character
0132:                        .codePointAt((CharSequence) "abc", 2));
0133:                assertEquals(0x10000, Character.codePointAt(
0134:                        (CharSequence) "\uD800\uDC00", 0));
0135:                assertEquals('\uDC00', Character.codePointAt(
0136:                        (CharSequence) "\uD800\uDC00", 1));
0137:
0138:                try {
0139:                    Character.codePointAt((CharSequence) null, 0);
0140:                    fail("No NPE.");
0141:                } catch (NullPointerException e) {
0142:                }
0143:
0144:                try {
0145:                    Character.codePointAt((CharSequence) "abc", -1);
0146:                    fail("No IOOBE, negative index.");
0147:                } catch (IndexOutOfBoundsException e) {
0148:                }
0149:
0150:                try {
0151:                    Character.codePointAt((CharSequence) "abc", 4);
0152:                    fail("No IOOBE, index too large.");
0153:                } catch (IndexOutOfBoundsException e) {
0154:                }
0155:            }
0156:
0157:            public void test_codePointAt$CI() {
0158:
0159:                assertEquals('a', Character.codePointAt("abc".toCharArray(), 0));
0160:                assertEquals('b', Character.codePointAt("abc".toCharArray(), 1));
0161:                assertEquals('c', Character.codePointAt("abc".toCharArray(), 2));
0162:                assertEquals(0x10000, Character.codePointAt("\uD800\uDC00"
0163:                        .toCharArray(), 0));
0164:                assertEquals('\uDC00', Character.codePointAt("\uD800\uDC00"
0165:                        .toCharArray(), 1));
0166:
0167:                try {
0168:                    Character.codePointAt((char[]) null, 0);
0169:                    fail("No NPE.");
0170:                } catch (NullPointerException e) {
0171:                }
0172:
0173:                try {
0174:                    Character.codePointAt("abc".toCharArray(), -1);
0175:                    fail("No IOOBE, negative index.");
0176:                } catch (IndexOutOfBoundsException e) {
0177:                }
0178:
0179:                try {
0180:                    Character.codePointAt("abc".toCharArray(), 4);
0181:                    fail("No IOOBE, index too large.");
0182:                } catch (IndexOutOfBoundsException e) {
0183:                }
0184:            }
0185:
0186:            public void test_codePointAt$CII() {
0187:
0188:                assertEquals('a', Character.codePointAt("abc".toCharArray(), 0,
0189:                        3));
0190:                assertEquals('b', Character.codePointAt("abc".toCharArray(), 1,
0191:                        3));
0192:                assertEquals('c', Character.codePointAt("abc".toCharArray(), 2,
0193:                        3));
0194:                assertEquals(0x10000, Character.codePointAt("\uD800\uDC00"
0195:                        .toCharArray(), 0, 2));
0196:                assertEquals('\uDC00', Character.codePointAt("\uD800\uDC00"
0197:                        .toCharArray(), 1, 2));
0198:                assertEquals('\uD800', Character.codePointAt("\uD800\uDC00"
0199:                        .toCharArray(), 0, 1));
0200:
0201:                try {
0202:                    Character.codePointAt((char[]) null, 0, 1);
0203:                    fail("No NPE.");
0204:                } catch (NullPointerException e) {
0205:                }
0206:
0207:                try {
0208:                    Character.codePointAt("abc".toCharArray(), -1, 3);
0209:                    fail("No IOOBE, negative index.");
0210:                } catch (IndexOutOfBoundsException e) {
0211:                }
0212:
0213:                try {
0214:                    Character.codePointAt("abc".toCharArray(), 4, 3);
0215:                    fail("No IOOBE, index too large.");
0216:                } catch (IndexOutOfBoundsException e) {
0217:                }
0218:
0219:                try {
0220:                    Character.codePointAt("abc".toCharArray(), 2, 1);
0221:                    fail("No IOOBE, index larger than limit.");
0222:                } catch (IndexOutOfBoundsException e) {
0223:                }
0224:
0225:                try {
0226:                    Character.codePointAt("abc".toCharArray(), 2, -1);
0227:                    fail("No IOOBE, limit is negative.");
0228:                } catch (IndexOutOfBoundsException e) {
0229:                }
0230:            }
0231:
0232:            @SuppressWarnings("cast")
0233:            public void test_codePointBeforeLjava_lang_CharSequenceI() {
0234:
0235:                assertEquals('a', Character.codePointBefore(
0236:                        (CharSequence) "abc", 1));
0237:                assertEquals('b', Character.codePointBefore(
0238:                        (CharSequence) "abc", 2));
0239:                assertEquals('c', Character.codePointBefore(
0240:                        (CharSequence) "abc", 3));
0241:                assertEquals(0x10000, Character.codePointBefore(
0242:                        (CharSequence) "\uD800\uDC00", 2));
0243:                assertEquals('\uD800', Character.codePointBefore(
0244:                        (CharSequence) "\uD800\uDC00", 1));
0245:
0246:                try {
0247:                    Character.codePointBefore((CharSequence) null, 0);
0248:                    fail("No NPE.");
0249:                } catch (NullPointerException e) {
0250:                }
0251:
0252:                try {
0253:                    Character.codePointBefore((CharSequence) "abc", 0);
0254:                    fail("No IOOBE, index below one.");
0255:                } catch (IndexOutOfBoundsException e) {
0256:                }
0257:
0258:                try {
0259:                    Character.codePointBefore((CharSequence) "abc", 4);
0260:                    fail("No IOOBE, index too large.");
0261:                } catch (IndexOutOfBoundsException e) {
0262:                }
0263:            }
0264:
0265:            public void test_codePointBefore$CI() {
0266:
0267:                assertEquals('a', Character.codePointBefore(
0268:                        "abc".toCharArray(), 1));
0269:                assertEquals('b', Character.codePointBefore(
0270:                        "abc".toCharArray(), 2));
0271:                assertEquals('c', Character.codePointBefore(
0272:                        "abc".toCharArray(), 3));
0273:                assertEquals(0x10000, Character.codePointBefore("\uD800\uDC00"
0274:                        .toCharArray(), 2));
0275:                assertEquals('\uD800', Character.codePointBefore("\uD800\uDC00"
0276:                        .toCharArray(), 1));
0277:
0278:                try {
0279:                    Character.codePointBefore((char[]) null, 0);
0280:                    fail("No NPE.");
0281:                } catch (NullPointerException e) {
0282:                }
0283:
0284:                try {
0285:                    Character.codePointBefore("abc".toCharArray(), -1);
0286:                    fail("No IOOBE, negative index.");
0287:                } catch (IndexOutOfBoundsException e) {
0288:                }
0289:
0290:                try {
0291:                    Character.codePointBefore("abc".toCharArray(), 4);
0292:                    fail("No IOOBE, index too large.");
0293:                } catch (IndexOutOfBoundsException e) {
0294:                }
0295:            }
0296:
0297:            public void test_codePointBefore$CII() {
0298:
0299:                assertEquals('a', Character.codePointBefore(
0300:                        "abc".toCharArray(), 1, 0));
0301:                assertEquals('b', Character.codePointBefore(
0302:                        "abc".toCharArray(), 2, 0));
0303:                assertEquals('c', Character.codePointBefore(
0304:                        "abc".toCharArray(), 3, 0));
0305:                assertEquals(0x10000, Character.codePointBefore("\uD800\uDC00"
0306:                        .toCharArray(), 2, 0));
0307:                assertEquals('\uDC00', Character.codePointBefore("\uD800\uDC00"
0308:                        .toCharArray(), 2, 1));
0309:                assertEquals('\uD800', Character.codePointBefore("\uD800\uDC00"
0310:                        .toCharArray(), 1, 0));
0311:
0312:                try {
0313:                    Character.codePointBefore((char[]) null, 1, 0);
0314:                    fail("No NPE.");
0315:                } catch (NullPointerException e) {
0316:                }
0317:
0318:                try {
0319:                    Character.codePointBefore("abc".toCharArray(), 0, 1);
0320:                    fail("No IOOBE, index less than start.");
0321:                } catch (IndexOutOfBoundsException e) {
0322:                }
0323:
0324:                try {
0325:                    Character.codePointBefore("abc".toCharArray(), 4, 0);
0326:                    fail("No IOOBE, index larger than length.");
0327:                } catch (IndexOutOfBoundsException e) {
0328:                }
0329:
0330:                try {
0331:                    Character.codePointBefore("abc".toCharArray(), 2, -1);
0332:                    fail("No IOOBE, start is negative.");
0333:                } catch (IndexOutOfBoundsException e) {
0334:                }
0335:
0336:                try {
0337:                    Character.codePointBefore("abc".toCharArray(), 2, 4);
0338:                    fail("No IOOBE, start larger than length.");
0339:                } catch (IndexOutOfBoundsException e) {
0340:                }
0341:            }
0342:
0343:            public void test_toCharsI$CI() {
0344:                char[] dst = new char[2];
0345:                int result = Character.toChars(0x10000, dst, 0);
0346:                assertEquals(2, result);
0347:                assertTrue(Arrays
0348:                        .equals(new char[] { '\uD800', '\uDC00' }, dst));
0349:
0350:                result = Character.toChars(0x10001, dst, 0);
0351:                assertEquals(2, result);
0352:                assertTrue(Arrays
0353:                        .equals(new char[] { '\uD800', '\uDC01' }, dst));
0354:
0355:                result = Character.toChars(0x10401, dst, 0);
0356:                assertEquals(2, result);
0357:                assertTrue(Arrays
0358:                        .equals(new char[] { '\uD801', '\uDC01' }, dst));
0359:
0360:                result = Character.toChars(0x10FFFF, dst, 0);
0361:                assertEquals(2, result);
0362:                assertTrue(Arrays
0363:                        .equals(new char[] { '\uDBFF', '\uDFFF' }, dst));
0364:
0365:                try {
0366:                    Character.toChars(Integer.MAX_VALUE, new char[2], 0);
0367:                    fail("No IAE, invalid code point.");
0368:                } catch (IllegalArgumentException e) {
0369:                }
0370:
0371:                try {
0372:                    Character.toChars('a', null, 0);
0373:                    fail("No NPE, null char[].");
0374:                } catch (NullPointerException e) {
0375:                }
0376:
0377:                try {
0378:                    Character.toChars('a', new char[1], -1);
0379:                    fail("No IOOBE, negative index.");
0380:                } catch (IndexOutOfBoundsException e) {
0381:                }
0382:
0383:                try {
0384:                    Character.toChars('a', new char[1], 1);
0385:                    fail("No IOOBE, index equal to length.");
0386:                } catch (IndexOutOfBoundsException e) {
0387:                }
0388:            }
0389:
0390:            public void test_toCharsI() {
0391:                assertTrue(Arrays.equals(new char[] { '\uD800', '\uDC00' },
0392:                        Character.toChars(0x10000)));
0393:                assertTrue(Arrays.equals(new char[] { '\uD800', '\uDC01' },
0394:                        Character.toChars(0x10001)));
0395:                assertTrue(Arrays.equals(new char[] { '\uD801', '\uDC01' },
0396:                        Character.toChars(0x10401)));
0397:                assertTrue(Arrays.equals(new char[] { '\uDBFF', '\uDFFF' },
0398:                        Character.toChars(0x10FFFF)));
0399:
0400:                try {
0401:                    Character.toChars(Integer.MAX_VALUE);
0402:                    fail("No IAE, invalid code point.");
0403:                } catch (IllegalArgumentException e) {
0404:                }
0405:            }
0406:
0407:            public void test_codePointCountLjava_lang_CharSequenceII() {
0408:                assertEquals(1, Character.codePointCount("\uD800\uDC00", 0, 2));
0409:                assertEquals(1, Character.codePointCount("\uD800\uDC01", 0, 2));
0410:                assertEquals(1, Character.codePointCount("\uD801\uDC01", 0, 2));
0411:                assertEquals(1, Character.codePointCount("\uDBFF\uDFFF", 0, 2));
0412:
0413:                assertEquals(3, Character
0414:                        .codePointCount("a\uD800\uDC00b", 0, 4));
0415:                assertEquals(4, Character.codePointCount(
0416:                        "a\uD800\uDC00b\uD800", 0, 5));
0417:
0418:                try {
0419:                    Character.codePointCount((CharSequence) null, 0, 1);
0420:                    fail("No NPE, null char sequence.");
0421:                } catch (NullPointerException e) {
0422:                }
0423:
0424:                try {
0425:                    Character.codePointCount("abc", -1, 1);
0426:                    fail("No IOOBE, negative start.");
0427:                } catch (IndexOutOfBoundsException e) {
0428:                }
0429:
0430:                try {
0431:                    Character.codePointCount("abc", 0, 4);
0432:                    fail("No IOOBE, end greater than length.");
0433:                } catch (IndexOutOfBoundsException e) {
0434:                }
0435:
0436:                try {
0437:                    Character.codePointCount("abc", 2, 1);
0438:                    fail("No IOOBE, end greater than start.");
0439:                } catch (IndexOutOfBoundsException e) {
0440:                }
0441:            }
0442:
0443:            public void test_offsetByCodePointsLjava_lang_CharSequenceII() {
0444:                int result = Character.offsetByCodePoints("a\uD800\uDC00b", 0,
0445:                        2);
0446:                assertEquals(3, result);
0447:
0448:                result = Character.offsetByCodePoints("abcd", 3, -1);
0449:                assertEquals(2, result);
0450:
0451:                result = Character.offsetByCodePoints("a\uD800\uDC00b", 0, 3);
0452:                assertEquals(4, result);
0453:
0454:                result = Character.offsetByCodePoints("a\uD800\uDC00b", 3, -1);
0455:                assertEquals(1, result);
0456:
0457:                result = Character.offsetByCodePoints("a\uD800\uDC00b", 3, 0);
0458:                assertEquals(3, result);
0459:
0460:                result = Character.offsetByCodePoints("\uD800\uDC00bc", 3, 0);
0461:                assertEquals(3, result);
0462:
0463:                result = Character.offsetByCodePoints("a\uDC00bc", 3, -1);
0464:                assertEquals(2, result);
0465:
0466:                result = Character.offsetByCodePoints("a\uD800bc", 3, -1);
0467:                assertEquals(2, result);
0468:
0469:                try {
0470:                    Character.offsetByCodePoints((CharSequence) null, 0, 1);
0471:                    fail();
0472:                } catch (NullPointerException e) {
0473:                }
0474:
0475:                try {
0476:                    Character.offsetByCodePoints("abc", -1, 1);
0477:                    fail();
0478:                } catch (IndexOutOfBoundsException e) {
0479:                }
0480:
0481:                try {
0482:                    Character.offsetByCodePoints("abc", 4, 1);
0483:                    fail();
0484:                } catch (IndexOutOfBoundsException e) {
0485:                }
0486:
0487:                try {
0488:                    Character.offsetByCodePoints("abc", 1, 3);
0489:                    fail();
0490:                } catch (IndexOutOfBoundsException e) {
0491:                }
0492:
0493:                try {
0494:                    Character.offsetByCodePoints("abc", 1, -2);
0495:                    fail();
0496:                } catch (IndexOutOfBoundsException e) {
0497:                }
0498:            }
0499:
0500:            public void test_offsetByCodePoints$CIIII() {
0501:                int result = Character.offsetByCodePoints("a\uD800\uDC00b"
0502:                        .toCharArray(), 0, 4, 0, 2);
0503:                assertEquals(3, result);
0504:
0505:                result = Character.offsetByCodePoints("a\uD800\uDC00b"
0506:                        .toCharArray(), 0, 4, 0, 3);
0507:                assertEquals(4, result);
0508:
0509:                result = Character.offsetByCodePoints("a\uD800\uDC00b\uD800c"
0510:                        .toCharArray(), 0, 5, 0, 3);
0511:                assertEquals(4, result);
0512:
0513:                result = Character.offsetByCodePoints("abcd".toCharArray(), 0,
0514:                        4, 3, -1);
0515:                assertEquals(2, result);
0516:
0517:                result = Character.offsetByCodePoints("abcd".toCharArray(), 1,
0518:                        2, 3, -2);
0519:                assertEquals(1, result);
0520:
0521:                result = Character.offsetByCodePoints("a\uD800\uDC00b"
0522:                        .toCharArray(), 0, 4, 3, -1);
0523:                assertEquals(1, result);
0524:
0525:                result = Character.offsetByCodePoints("a\uD800\uDC00b"
0526:                        .toCharArray(), 0, 2, 2, -1);
0527:                assertEquals(1, result);
0528:
0529:                result = Character.offsetByCodePoints("a\uD800\uDC00b"
0530:                        .toCharArray(), 0, 4, 3, 0);
0531:                assertEquals(3, result);
0532:
0533:                result = Character.offsetByCodePoints("\uD800\uDC00bc"
0534:                        .toCharArray(), 0, 4, 3, 0);
0535:                assertEquals(3, result);
0536:
0537:                result = Character.offsetByCodePoints(
0538:                        "a\uDC00bc".toCharArray(), 0, 4, 3, -1);
0539:                assertEquals(2, result);
0540:
0541:                result = Character.offsetByCodePoints(
0542:                        "a\uD800bc".toCharArray(), 0, 4, 3, -1);
0543:                assertEquals(2, result);
0544:
0545:                try {
0546:                    Character.offsetByCodePoints(null, 0, 4, 1, 1);
0547:                    fail();
0548:                } catch (NullPointerException e) {
0549:                }
0550:
0551:                try {
0552:                    Character.offsetByCodePoints("abcd".toCharArray(), -1, 4,
0553:                            1, 1);
0554:                    fail();
0555:                } catch (IndexOutOfBoundsException e) {
0556:                }
0557:
0558:                try {
0559:                    Character.offsetByCodePoints("abcd".toCharArray(), 0, -1,
0560:                            1, 1);
0561:                    fail();
0562:                } catch (IndexOutOfBoundsException e) {
0563:                }
0564:
0565:                try {
0566:                    Character.offsetByCodePoints("abcd".toCharArray(), 2, 4, 1,
0567:                            1);
0568:                    fail();
0569:                } catch (IndexOutOfBoundsException e) {
0570:                }
0571:
0572:                try {
0573:                    Character.offsetByCodePoints("abcd".toCharArray(), 1, 3, 0,
0574:                            1);
0575:                    fail();
0576:                } catch (IndexOutOfBoundsException e) {
0577:                }
0578:
0579:                try {
0580:                    Character.offsetByCodePoints("abcd".toCharArray(), 1, 1, 3,
0581:                            1);
0582:                    fail();
0583:                } catch (IndexOutOfBoundsException e) {
0584:                }
0585:
0586:                try {
0587:                    Character.offsetByCodePoints("abc".toCharArray(), 0, 3, 1,
0588:                            3);
0589:                    fail();
0590:                } catch (IndexOutOfBoundsException e) {
0591:                }
0592:
0593:                try {
0594:                    Character.offsetByCodePoints("abc".toCharArray(), 0, 2, 1,
0595:                            2);
0596:                    fail();
0597:                } catch (IndexOutOfBoundsException e) {
0598:                }
0599:
0600:                try {
0601:                    Character.offsetByCodePoints("abc".toCharArray(), 1, 3, 1,
0602:                            -2);
0603:                    fail();
0604:                } catch (IndexOutOfBoundsException e) {
0605:                }
0606:            }
0607:
0608:            /**
0609:             * @tests java.lang.Character#compareTo(Character)
0610:             */
0611:            public void test_compareToLjava_lang_Byte() {
0612:                final Character min = new Character(Character.MIN_VALUE);
0613:                final Character mid = new Character(
0614:                        (char) (Character.MAX_VALUE / 2));
0615:                final Character max = new Character(Character.MAX_VALUE);
0616:
0617:                assertTrue(max.compareTo(max) == 0);
0618:                assertTrue(min.compareTo(min) == 0);
0619:                assertTrue(mid.compareTo(mid) == 0);
0620:
0621:                assertTrue(max.compareTo(mid) > 0);
0622:                assertTrue(max.compareTo(min) > 0);
0623:
0624:                assertTrue(mid.compareTo(max) < 0);
0625:                assertTrue(mid.compareTo(min) > 0);
0626:
0627:                assertTrue(min.compareTo(mid) < 0);
0628:                assertTrue(min.compareTo(max) < 0);
0629:
0630:                try {
0631:                    min.compareTo(null);
0632:                    fail("No NPE");
0633:                } catch (NullPointerException e) {
0634:                }
0635:            }
0636:
0637:            public void test_codePointAt_Invalid() {
0638:
0639:                try {
0640:                    Character.codePointAt(null, 6, 4);
0641:                    fail("Expected IndexOutOfBoundsException");
0642:                } catch (IndexOutOfBoundsException e) {
0643:                    // expected
0644:                }
0645:
0646:                try {
0647:                    Character.codePointAt(null, 4, 6);
0648:                    fail("Expected NullPointerException");
0649:                } catch (NullPointerException e) {
0650:                    // expected
0651:                }
0652:
0653:                try {
0654:                    Character.codePointAt(null, 0, 0);
0655:                    fail("Expected IndexOutOfBoundsException");
0656:                } catch (IndexOutOfBoundsException e) {
0657:                    // expected
0658:                }
0659:            }
0660:
0661:            /**
0662:             * @tests java.lang.Character#Character(char)
0663:             */
0664:            public void test_ConstructorC() {
0665:                assertEquals("Constructor failed", 'T', new Character('T')
0666:                        .charValue());
0667:            }
0668:
0669:            /**
0670:             * @tests java.lang.Character#charValue()
0671:             */
0672:            public void test_charValue() {
0673:                assertEquals("Incorrect char value returned", 'T',
0674:                        new Character('T').charValue());
0675:            }
0676:
0677:            /**
0678:             * @tests java.lang.Character#compareTo(java.lang.Character)
0679:             */
0680:            public void test_compareToLjava_lang_Character() {
0681:                Character c = new Character('c');
0682:                Character x = new Character('c');
0683:                Character y = new Character('b');
0684:                Character z = new Character('d');
0685:
0686:                assertEquals("Returned false for same Character", 0, c
0687:                        .compareTo(c));
0688:                assertEquals("Returned false for identical Character", 0, c
0689:                        .compareTo(x));
0690:                assertTrue("Returned other than less than for lesser char", c
0691:                        .compareTo(y) > 0);
0692:                assertTrue("Returned other than greater than for greater char",
0693:                        c.compareTo(z) < 0);
0694:            }
0695:
0696:            /**
0697:             * @tests java.lang.Character#digit(char, int)
0698:             */
0699:            public void test_digitCI() {
0700:                assertEquals("Returned incorrect digit", 1, Character.digit(
0701:                        '1', 10));
0702:                assertEquals("Returned incorrect digit", 15, Character.digit(
0703:                        'F', 16));
0704:            }
0705:
0706:            /**
0707:             * @tests java.lang.Character#digit(int, int)
0708:             */
0709:            public void test_digit_II() {
0710:                assertEquals(1, Character.digit((int) '1', 10));
0711:                assertEquals(15, Character.digit((int) 'F', 16));
0712:
0713:                assertEquals(-1, Character.digit(0x0000, 37));
0714:                assertEquals(-1, Character.digit(0x0045, 10));
0715:
0716:                assertEquals(10, Character.digit(0x0041, 20));
0717:                assertEquals(10, Character.digit(0x0061, 20));
0718:
0719:                assertEquals(-1, Character.digit(0x110000, 20));
0720:            }
0721:
0722:            /**
0723:             * @tests java.lang.Character#equals(java.lang.Object)
0724:             */
0725:            public void test_equalsLjava_lang_Object() {
0726:                // Test for method boolean java.lang.Character.equals(java.lang.Object)
0727:                assertTrue("Equality test failed", new Character('A')
0728:                        .equals(new Character('A')));
0729:                assertTrue("Equality test failed", !(new Character('A')
0730:                        .equals(new Character('a'))));
0731:            }
0732:
0733:            /**
0734:             * @tests java.lang.Character#forDigit(int, int)
0735:             */
0736:            public void test_forDigitII() {
0737:                char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7',
0738:                        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
0739:                for (int i = 0; i < hexChars.length; i++) {
0740:                    assertTrue("Returned incorrect char for "
0741:                            + Integer.toString(i), Character.forDigit(i,
0742:                            hexChars.length) == hexChars[i]);
0743:                }
0744:
0745:                char decimalChars[] = { '0', '1', '2', '3', '4', '5', '6', '7',
0746:                        '8', '9' };
0747:                for (int i = 0; i < decimalChars.length; i++) {
0748:                    assertTrue("Returned incorrect char for "
0749:                            + Integer.toString(i), Character.forDigit(i,
0750:                            decimalChars.length) == decimalChars[i]);
0751:                }
0752:
0753:            }
0754:
0755:            /**
0756:             * @tests java.lang.Character#getNumericValue(char)
0757:             */
0758:            public void test_getNumericValueC() {
0759:                assertEquals("Returned incorrect numeric value 1", 1, Character
0760:                        .getNumericValue('1'));
0761:                assertEquals("Returned incorrect numeric value 2", 15,
0762:                        Character.getNumericValue('F'));
0763:                assertEquals("Returned incorrect numeric value 3", -1,
0764:                        Character.getNumericValue('\u221e'));
0765:                assertEquals("Returned incorrect numeric value 4", -2,
0766:                        Character.getNumericValue('\u00be'));
0767:                assertEquals("Returned incorrect numeric value 5", 10000,
0768:                        Character.getNumericValue('\u2182'));
0769:                assertEquals("Returned incorrect numeric value 6", 2, Character
0770:                        .getNumericValue('\uff12'));
0771:            }
0772:
0773:            /**
0774:             * @tests java.lang.Character#getNumericValue(int)
0775:             */
0776:            public void test_getNumericValue_I() {
0777:                assertEquals(1, Character.getNumericValue((int) '1'));
0778:                assertEquals(15, Character.getNumericValue((int) 'F'));
0779:                assertEquals(-1, Character.getNumericValue((int) '\u221e'));
0780:                assertEquals(-2, Character.getNumericValue((int) '\u00be'));
0781:                assertEquals(10000, Character.getNumericValue((int) '\u2182'));
0782:                assertEquals(2, Character.getNumericValue((int) '\uff12'));
0783:                assertEquals(-1, Character.getNumericValue(0xFFFF));
0784:
0785:                assertEquals(-1, Character.getNumericValue(0xFFFF));
0786:                assertEquals(0, Character.getNumericValue(0x1D7CE));
0787:                assertEquals(0, Character.getNumericValue(0x1D7D8));
0788:                assertEquals(-1, Character.getNumericValue(0x2F800));
0789:                assertEquals(-1, Character.getNumericValue(0x10FFFD));
0790:                assertEquals(-1, Character.getNumericValue(0x110000));
0791:
0792:                assertEquals(50, Character.getNumericValue(0x216C));
0793:
0794:                assertEquals(10, Character.getNumericValue(0x0041));
0795:                assertEquals(35, Character.getNumericValue(0x005A));
0796:                assertEquals(10, Character.getNumericValue(0x0061));
0797:                assertEquals(35, Character.getNumericValue(0x007A));
0798:                assertEquals(10, Character.getNumericValue(0xFF21));
0799:
0800:                //FIXME depends on ICU4J
0801:                //assertEquals(35, Character.getNumericValue(0xFF3A));
0802:
0803:                assertEquals(10, Character.getNumericValue(0xFF41));
0804:                assertEquals(35, Character.getNumericValue(0xFF5A));
0805:            }
0806:
0807:            /**
0808:             * @tests java.lang.Character#getType(char)
0809:             */
0810:            public void test_getTypeC() {
0811:                assertTrue("Returned incorrect type for: \n", Character
0812:                        .getType('\n') == Character.CONTROL);
0813:                assertTrue("Returned incorrect type for: 1", Character
0814:                        .getType('1') == Character.DECIMAL_DIGIT_NUMBER);
0815:                assertTrue("Returned incorrect type for: ' '", Character
0816:                        .getType(' ') == Character.SPACE_SEPARATOR);
0817:                assertTrue("Returned incorrect type for: a", Character
0818:                        .getType('a') == Character.LOWERCASE_LETTER);
0819:                assertTrue("Returned incorrect type for: A", Character
0820:                        .getType('A') == Character.UPPERCASE_LETTER);
0821:                assertTrue("Returned incorrect type for: <", Character
0822:                        .getType('<') == Character.MATH_SYMBOL);
0823:                assertTrue("Returned incorrect type for: ;", Character
0824:                        .getType(';') == Character.OTHER_PUNCTUATION);
0825:                assertTrue("Returned incorrect type for: _", Character
0826:                        .getType('_') == Character.CONNECTOR_PUNCTUATION);
0827:                assertTrue("Returned incorrect type for: $", Character
0828:                        .getType('$') == Character.CURRENCY_SYMBOL);
0829:                assertTrue("Returned incorrect type for: \u2029", Character
0830:                        .getType('\u2029') == Character.PARAGRAPH_SEPARATOR);
0831:
0832:                assertEquals("Wrong constant for FORMAT", 16, Character.FORMAT);
0833:                assertEquals("Wrong constant for PRIVATE_USE", 18,
0834:                        Character.PRIVATE_USE);
0835:            }
0836:
0837:            /**
0838:             * @tests java.lang.Character#getType(int)
0839:             */
0840:            public void test_getType_I() {
0841:                assertTrue(Character.getType((int) '\n') == Character.CONTROL);
0842:                assertTrue(Character.getType((int) '1') == Character.DECIMAL_DIGIT_NUMBER);
0843:                assertTrue(Character.getType((int) ' ') == Character.SPACE_SEPARATOR);
0844:                assertTrue(Character.getType((int) 'a') == Character.LOWERCASE_LETTER);
0845:                assertTrue(Character.getType((int) 'A') == Character.UPPERCASE_LETTER);
0846:                assertTrue(Character.getType((int) '<') == Character.MATH_SYMBOL);
0847:                assertTrue(Character.getType((int) ';') == Character.OTHER_PUNCTUATION);
0848:                assertTrue(Character.getType((int) '_') == Character.CONNECTOR_PUNCTUATION);
0849:                assertTrue(Character.getType((int) '$') == Character.CURRENCY_SYMBOL);
0850:                assertTrue(Character.getType((int) '\u2029') == Character.PARAGRAPH_SEPARATOR);
0851:
0852:                assertTrue(Character.getType(0x9FFF) == Character.UNASSIGNED);
0853:                assertTrue(Character.getType(0x30000) == Character.UNASSIGNED);
0854:                assertTrue(Character.getType(0x110000) == Character.UNASSIGNED);
0855:
0856:                assertTrue(Character.getType(0x0041) == Character.UPPERCASE_LETTER);
0857:                assertTrue(Character.getType(0x10400) == Character.UPPERCASE_LETTER);
0858:
0859:                assertTrue(Character.getType(0x0061) == Character.LOWERCASE_LETTER);
0860:                assertTrue(Character.getType(0x10428) == Character.LOWERCASE_LETTER);
0861:
0862:                assertTrue(Character.getType(0x01C5) == Character.TITLECASE_LETTER);
0863:                assertTrue(Character.getType(0x1FFC) == Character.TITLECASE_LETTER);
0864:
0865:                assertTrue(Character.getType(0x02B0) == Character.MODIFIER_LETTER);
0866:                assertTrue(Character.getType(0xFF9F) == Character.MODIFIER_LETTER);
0867:
0868:                assertTrue(Character.getType(0x01BB) == Character.OTHER_LETTER);
0869:                assertTrue(Character.getType(0x2F888) == Character.OTHER_LETTER);
0870:
0871:                assertTrue(Character.getType(0x0F82) == Character.NON_SPACING_MARK);
0872:                assertTrue(Character.getType(0x1D180) == Character.NON_SPACING_MARK);
0873:
0874:                assertTrue(Character.getType(0x0488) == Character.ENCLOSING_MARK);
0875:                assertTrue(Character.getType(0x20DE) == Character.ENCLOSING_MARK);
0876:
0877:                assertTrue(Character.getType(0x1938) == Character.COMBINING_SPACING_MARK);
0878:                assertTrue(Character.getType(0x1D165) == Character.COMBINING_SPACING_MARK);
0879:
0880:                assertTrue(Character.getType(0x194D) == Character.DECIMAL_DIGIT_NUMBER);
0881:                assertTrue(Character.getType(0x1D7CE) == Character.DECIMAL_DIGIT_NUMBER);
0882:
0883:                assertTrue(Character.getType(0x2160) == Character.LETTER_NUMBER);
0884:                assertTrue(Character.getType(0x1034A) == Character.LETTER_NUMBER);
0885:
0886:                assertTrue(Character.getType(0x00B2) == Character.OTHER_NUMBER);
0887:                assertTrue(Character.getType(0x10120) == Character.OTHER_NUMBER);
0888:
0889:                assertTrue(Character.getType(0x0020) == Character.SPACE_SEPARATOR);
0890:                assertTrue(Character.getType(0x3000) == Character.SPACE_SEPARATOR);
0891:
0892:                assertTrue(Character.getType(0x2028) == Character.LINE_SEPARATOR);
0893:
0894:                assertTrue(Character.getType(0x2029) == Character.PARAGRAPH_SEPARATOR);
0895:
0896:                assertTrue(Character.getType(0x0000) == Character.CONTROL);
0897:                assertTrue(Character.getType(0x009F) == Character.CONTROL);
0898:
0899:                assertTrue(Character.getType(0x00AD) == Character.FORMAT);
0900:                assertTrue(Character.getType(0xE007F) == Character.FORMAT);
0901:
0902:                assertTrue(Character.getType(0xE000) == Character.PRIVATE_USE);
0903:                assertTrue(Character.getType(0x10FFFD) == Character.PRIVATE_USE);
0904:
0905:                assertTrue(Character.getType(0xD800) == Character.SURROGATE);
0906:                assertTrue(Character.getType(0xDFFF) == Character.SURROGATE);
0907:
0908:                assertTrue(Character.getType(0xFE31) == Character.DASH_PUNCTUATION);
0909:                assertTrue(Character.getType(0xFF0D) == Character.DASH_PUNCTUATION);
0910:
0911:                assertTrue(Character.getType(0x0028) == Character.START_PUNCTUATION);
0912:                assertTrue(Character.getType(0xFF62) == Character.START_PUNCTUATION);
0913:
0914:                assertTrue(Character.getType(0x0029) == Character.END_PUNCTUATION);
0915:                assertTrue(Character.getType(0xFF63) == Character.END_PUNCTUATION);
0916:
0917:                assertTrue(Character.getType(0x005F) == Character.CONNECTOR_PUNCTUATION);
0918:                assertTrue(Character.getType(0xFF3F) == Character.CONNECTOR_PUNCTUATION);
0919:
0920:                assertTrue(Character.getType(0x2034) == Character.OTHER_PUNCTUATION);
0921:                assertTrue(Character.getType(0x1039F) == Character.OTHER_PUNCTUATION);
0922:
0923:                assertTrue(Character.getType(0x002B) == Character.MATH_SYMBOL);
0924:                assertTrue(Character.getType(0x1D6C1) == Character.MATH_SYMBOL);
0925:
0926:                assertTrue(Character.getType(0x0024) == Character.CURRENCY_SYMBOL);
0927:                assertTrue(Character.getType(0xFFE6) == Character.CURRENCY_SYMBOL);
0928:
0929:                assertTrue(Character.getType(0x005E) == Character.MODIFIER_SYMBOL);
0930:                assertTrue(Character.getType(0xFFE3) == Character.MODIFIER_SYMBOL);
0931:
0932:                assertTrue(Character.getType(0x00A6) == Character.OTHER_SYMBOL);
0933:                assertTrue(Character.getType(0x1D356) == Character.OTHER_SYMBOL);
0934:
0935:                assertTrue(Character.getType(0x00AB) == Character.INITIAL_QUOTE_PUNCTUATION);
0936:                assertTrue(Character.getType(0x2039) == Character.INITIAL_QUOTE_PUNCTUATION);
0937:
0938:                assertTrue(Character.getType(0x00BB) == Character.FINAL_QUOTE_PUNCTUATION);
0939:                assertTrue(Character.getType(0x203A) == Character.FINAL_QUOTE_PUNCTUATION);
0940:            }
0941:
0942:            /**
0943:             * @tests java.lang.Character#hashCode()
0944:             */
0945:            public void test_hashCode() {
0946:                assertEquals("Incorrect hash returned", 89, new Character('Y')
0947:                        .hashCode());
0948:            }
0949:
0950:            /**
0951:             * @tests java.lang.Character#isDefined(char)
0952:             */
0953:            public void test_isDefinedC() {
0954:                assertTrue("Defined character returned false", Character
0955:                        .isDefined('v'));
0956:                assertTrue("Defined character returned false", Character
0957:                        .isDefined('\u6039'));
0958:            }
0959:
0960:            /**
0961:             * @tests java.lang.Character#isDefined(int)
0962:             */
0963:            public void test_isDefined_I() {
0964:                assertTrue(Character.isDefined((int) 'v'));
0965:                assertTrue(Character.isDefined((int) '\u6039'));
0966:                assertTrue(Character.isDefined(0x10300));
0967:
0968:                assertFalse(Character.isDefined(0x30000));
0969:                assertFalse(Character.isDefined(0x3FFFF));
0970:                assertFalse(Character.isDefined(0x110000));
0971:            }
0972:
0973:            /**
0974:             * @tests java.lang.Character#isDigit(char)
0975:             */
0976:            public void test_isDigitC() {
0977:                assertTrue("Digit returned false", Character.isDigit('1'));
0978:                assertTrue("Non-Digit returned false", !Character.isDigit('A'));
0979:            }
0980:
0981:            /**
0982:             * @tests java.lang.Character#isDigit(int)
0983:             */
0984:            public void test_isDigit_I() {
0985:                assertTrue(Character.isDigit((int) '1'));
0986:                assertFalse(Character.isDigit((int) 'A'));
0987:
0988:                assertTrue(Character.isDigit(0x0030));
0989:                assertTrue(Character.isDigit(0x0035));
0990:                assertTrue(Character.isDigit(0x0039));
0991:
0992:                assertTrue(Character.isDigit(0x0660));
0993:                assertTrue(Character.isDigit(0x0665));
0994:                assertTrue(Character.isDigit(0x0669));
0995:
0996:                assertTrue(Character.isDigit(0x06F0));
0997:                assertTrue(Character.isDigit(0x06F5));
0998:                assertTrue(Character.isDigit(0x06F9));
0999:
1000:                assertTrue(Character.isDigit(0x0966));
1001:                assertTrue(Character.isDigit(0x096A));
1002:                assertTrue(Character.isDigit(0x096F));
1003:
1004:                assertTrue(Character.isDigit(0xFF10));
1005:                assertTrue(Character.isDigit(0xFF15));
1006:                assertTrue(Character.isDigit(0xFF19));
1007:
1008:                assertTrue(Character.isDigit(0x1D7CE));
1009:                assertTrue(Character.isDigit(0x1D7D8));
1010:
1011:                assertFalse(Character.isDigit(0x2F800));
1012:                assertFalse(Character.isDigit(0x10FFFD));
1013:                assertFalse(Character.isDigit(0x110000));
1014:            }
1015:
1016:            /**
1017:             * @tests java.lang.Character#isIdentifierIgnorable(char)
1018:             */
1019:            public void test_isIdentifierIgnorableC() {
1020:                assertTrue("Ignorable whitespace returned false", Character
1021:                        .isIdentifierIgnorable('\u0007'));
1022:                assertTrue(
1023:                        "Ignorable non - whitespace  control returned false",
1024:                        Character.isIdentifierIgnorable('\u000f'));
1025:                assertTrue("Ignorable join control returned false", Character
1026:                        .isIdentifierIgnorable('\u200e'));
1027:
1028:                // the spec is wrong, and our implementation is correct
1029:                assertTrue("Ignorable bidi control returned false", Character
1030:                        .isIdentifierIgnorable('\u202b'));
1031:
1032:                assertTrue("Ignorable format control returned false", Character
1033:                        .isIdentifierIgnorable('\u206c'));
1034:                assertTrue("Ignorable zero-width no-break returned false",
1035:                        Character.isIdentifierIgnorable('\ufeff'));
1036:
1037:                assertTrue("Non-Ignorable returned true", !Character
1038:                        .isIdentifierIgnorable('\u0065'));
1039:            }
1040:
1041:            /**
1042:             * @tests java.lang.Character#isIdentifierIgnorable(int)
1043:             */
1044:            public void test_isIdentifierIgnorable_I() {
1045:                assertTrue(Character.isIdentifierIgnorable(0x0000));
1046:                assertTrue(Character.isIdentifierIgnorable(0x0004));
1047:                assertTrue(Character.isIdentifierIgnorable(0x0008));
1048:
1049:                assertTrue(Character.isIdentifierIgnorable(0x000E));
1050:                assertTrue(Character.isIdentifierIgnorable(0x0013));
1051:                assertTrue(Character.isIdentifierIgnorable(0x001B));
1052:
1053:                assertTrue(Character.isIdentifierIgnorable(0x007F));
1054:                assertTrue(Character.isIdentifierIgnorable(0x008F));
1055:                assertTrue(Character.isIdentifierIgnorable(0x009F));
1056:
1057:                assertTrue(Character.isIdentifierIgnorable(0x202b));
1058:                assertTrue(Character.isIdentifierIgnorable(0x206c));
1059:                assertTrue(Character.isIdentifierIgnorable(0xfeff));
1060:                assertFalse(Character.isIdentifierIgnorable(0x0065));
1061:
1062:                assertTrue(Character.isIdentifierIgnorable(0x1D173));
1063:
1064:                assertFalse(Character.isIdentifierIgnorable(0x10FFFD));
1065:                assertFalse(Character.isIdentifierIgnorable(0x110000));
1066:            }
1067:
1068:            /**
1069:             * @tests java.lang.Character#isMirrored(char)
1070:             */
1071:            public void test_isMirrored_C() {
1072:                assertTrue(Character.isMirrored('\u0028'));
1073:                assertFalse(Character.isMirrored('\uFFFF'));
1074:            }
1075:
1076:            /**
1077:             * @tests java.lang.Character#isMirrored(int)
1078:             */
1079:            public void test_isMirrored_I() {
1080:                assertTrue(Character.isMirrored(0x0028));
1081:                assertFalse(Character.isMirrored(0xFFFF));
1082:                assertFalse(Character.isMirrored(0x110000));
1083:            }
1084:
1085:            /**
1086:             * @tests java.lang.Character#isISOControl(char)
1087:             */
1088:            public void test_isISOControlC() {
1089:                // Test for method boolean java.lang.Character.isISOControl(char)
1090:                for (int i = 0; i < 32; i++)
1091:                    assertTrue("ISOConstrol char returned false", Character
1092:                            .isISOControl((char) i));
1093:
1094:                for (int i = 127; i < 160; i++)
1095:                    assertTrue("ISOConstrol char returned false", Character
1096:                            .isISOControl((char) i));
1097:            }
1098:
1099:            /**
1100:             * @tests java.lang.Character#isISOControl(int)
1101:             */
1102:            public void test_isISOControlI() {
1103:                // Test for method boolean java.lang.Character.isISOControl(char)
1104:                for (int i = 0; i < 32; i++)
1105:                    assertTrue("ISOConstrol char returned false", Character
1106:                            .isISOControl(i));
1107:
1108:                for (int i = 127; i < 160; i++)
1109:                    assertTrue("ISOConstrol char returned false", Character
1110:                            .isISOControl(i));
1111:
1112:                for (int i = 160; i < 260; i++)
1113:                    assertFalse("Not ISOConstrol char returned true", Character
1114:                            .isISOControl(i));
1115:
1116:            }
1117:
1118:            /**
1119:             * @tests java.lang.Character#isJavaIdentifierPart(char)
1120:             */
1121:            public void test_isJavaIdentifierPartC() {
1122:                assertTrue("letter returned false", Character
1123:                        .isJavaIdentifierPart('l'));
1124:                assertTrue("currency returned false", Character
1125:                        .isJavaIdentifierPart('$'));
1126:                assertTrue("digit returned false", Character
1127:                        .isJavaIdentifierPart('9'));
1128:                assertTrue("connecting char returned false", Character
1129:                        .isJavaIdentifierPart('_'));
1130:                assertTrue("ignorable control returned true", !Character
1131:                        .isJavaIdentifierPart('\u200b'));
1132:                assertTrue("semi returned true", !Character
1133:                        .isJavaIdentifierPart(';'));
1134:            }
1135:
1136:            /**
1137:             * @tests java.lang.Character#isJavaIdentifierPart(int)
1138:             */
1139:            public void test_isJavaIdentifierPart_I() {
1140:                assertTrue(Character.isJavaIdentifierPart((int) 'l'));
1141:                assertTrue(Character.isJavaIdentifierPart((int) '$'));
1142:                assertTrue(Character.isJavaIdentifierPart((int) '9'));
1143:                assertTrue(Character.isJavaIdentifierPart((int) '_'));
1144:                assertFalse(Character.isJavaIdentifierPart((int) ';'));
1145:
1146:                assertTrue(Character.isJavaIdentifierPart(0x0041));
1147:                assertTrue(Character.isJavaIdentifierPart(0x10400));
1148:                assertTrue(Character.isJavaIdentifierPart(0x0061));
1149:                assertTrue(Character.isJavaIdentifierPart(0x10428));
1150:                assertTrue(Character.isJavaIdentifierPart(0x01C5));
1151:                assertTrue(Character.isJavaIdentifierPart(0x1FFC));
1152:                assertTrue(Character.isJavaIdentifierPart(0x02B0));
1153:                assertTrue(Character.isJavaIdentifierPart(0xFF9F));
1154:                assertTrue(Character.isJavaIdentifierPart(0x01BB));
1155:                assertTrue(Character.isJavaIdentifierPart(0x2F888));
1156:
1157:                assertTrue(Character.isJavaIdentifierPart(0x0024));
1158:                assertTrue(Character.isJavaIdentifierPart(0xFFE6));
1159:
1160:                assertTrue(Character.isJavaIdentifierPart(0x005F));
1161:                assertTrue(Character.isJavaIdentifierPart(0xFF3F));
1162:
1163:                assertTrue(Character.isJavaIdentifierPart(0x194D));
1164:                assertTrue(Character.isJavaIdentifierPart(0x1D7CE));
1165:                assertTrue(Character.isJavaIdentifierPart(0x2160));
1166:                assertTrue(Character.isJavaIdentifierPart(0x1034A));
1167:
1168:                assertTrue(Character.isJavaIdentifierPart(0x0F82));
1169:                assertTrue(Character.isJavaIdentifierPart(0x1D180));
1170:
1171:                assertTrue(Character.isJavaIdentifierPart(0x0000));
1172:                assertTrue(Character.isJavaIdentifierPart(0x0008));
1173:                assertTrue(Character.isJavaIdentifierPart(0x000E));
1174:                assertTrue(Character.isJavaIdentifierPart(0x001B));
1175:                assertTrue(Character.isJavaIdentifierPart(0x007F));
1176:                assertTrue(Character.isJavaIdentifierPart(0x009F));
1177:                assertTrue(Character.isJavaIdentifierPart(0x00AD));
1178:                assertTrue(Character.isJavaIdentifierPart(0xE007F));
1179:
1180:                //RI fails because 0x200B changes category in Unicode 4.1
1181:                assertTrue(Character.isJavaIdentifierPart(0x200B));
1182:            }
1183:
1184:            /**
1185:             * @tests java.lang.Character#isJavaIdentifierStart(char)
1186:             */
1187:            public void test_isJavaIdentifierStartC() {
1188:                assertTrue("letter returned false", Character
1189:                        .isJavaIdentifierStart('l'));
1190:                assertTrue("currency returned false", Character
1191:                        .isJavaIdentifierStart('$'));
1192:                assertTrue("connecting char returned false", Character
1193:                        .isJavaIdentifierStart('_'));
1194:                assertTrue("digit returned true", !Character
1195:                        .isJavaIdentifierStart('9'));
1196:                assertTrue("ignorable control returned true", !Character
1197:                        .isJavaIdentifierStart('\u200b'));
1198:                assertTrue("semi returned true", !Character
1199:                        .isJavaIdentifierStart(';'));
1200:            }
1201:
1202:            /**
1203:             * @tests java.lang.Character#isJavaIdentifierStart(int)
1204:             */
1205:            public void test_isJavaIdentifierStart_I() {
1206:                assertTrue(Character.isJavaIdentifierStart((int) 'l'));
1207:                assertTrue(Character.isJavaIdentifierStart((int) '$'));
1208:                assertTrue(Character.isJavaIdentifierStart((int) '_'));
1209:                assertFalse(Character.isJavaIdentifierStart((int) '9'));
1210:                assertFalse(Character.isJavaIdentifierStart((int) '\u200b'));
1211:                assertFalse(Character.isJavaIdentifierStart((int) ';'));
1212:
1213:                assertTrue(Character.isJavaIdentifierStart(0x0041));
1214:                assertTrue(Character.isJavaIdentifierStart(0x10400));
1215:                assertTrue(Character.isJavaIdentifierStart(0x0061));
1216:                assertTrue(Character.isJavaIdentifierStart(0x10428));
1217:                assertTrue(Character.isJavaIdentifierStart(0x01C5));
1218:                assertTrue(Character.isJavaIdentifierStart(0x1FFC));
1219:                assertTrue(Character.isJavaIdentifierStart(0x02B0));
1220:                assertTrue(Character.isJavaIdentifierStart(0xFF9F));
1221:                assertTrue(Character.isJavaIdentifierStart(0x01BB));
1222:                assertTrue(Character.isJavaIdentifierStart(0x2F888));
1223:
1224:                assertTrue(Character.isJavaIdentifierPart(0x0024));
1225:                assertTrue(Character.isJavaIdentifierPart(0xFFE6));
1226:
1227:                assertTrue(Character.isJavaIdentifierPart(0x005F));
1228:                assertTrue(Character.isJavaIdentifierPart(0xFF3F));
1229:
1230:                assertTrue(Character.isJavaIdentifierPart(0x2160));
1231:                assertTrue(Character.isJavaIdentifierPart(0x1034A));
1232:
1233:                assertFalse(Character.isJavaIdentifierPart(0x110000));
1234:            }
1235:
1236:            /**
1237:             * @tests java.lang.Character#isJavaLetter(char)
1238:             */
1239:            @SuppressWarnings("deprecation")
1240:            public void test_isJavaLetterC() {
1241:                assertTrue("letter returned false", Character.isJavaLetter('l'));
1242:                assertTrue("currency returned false", Character
1243:                        .isJavaLetter('$'));
1244:                assertTrue("connecting char returned false", Character
1245:                        .isJavaLetter('_'));
1246:
1247:                assertTrue("digit returned true", !Character.isJavaLetter('9'));
1248:                assertTrue("ignored control returned true", !Character
1249:                        .isJavaLetter('\u200b'));
1250:                assertTrue("semi returned true", !Character.isJavaLetter(';'));
1251:            }
1252:
1253:            /**
1254:             * @tests java.lang.Character#isJavaLetterOrDigit(char)
1255:             */
1256:            @SuppressWarnings("deprecation")
1257:            public void test_isJavaLetterOrDigitC() {
1258:                assertTrue("letter returned false", Character
1259:                        .isJavaLetterOrDigit('l'));
1260:                assertTrue("currency returned false", Character
1261:                        .isJavaLetterOrDigit('$'));
1262:                assertTrue("digit returned false", Character
1263:                        .isJavaLetterOrDigit('9'));
1264:                assertTrue("connecting char returned false", Character
1265:                        .isJavaLetterOrDigit('_'));
1266:                assertTrue("semi returned true", !Character
1267:                        .isJavaLetterOrDigit(';'));
1268:            }
1269:
1270:            /**
1271:             * @tests java.lang.Character#isLetter(char)
1272:             */
1273:            public void test_isLetterC() {
1274:                assertTrue("Letter returned false", Character.isLetter('L'));
1275:                assertTrue("Non-Letter returned true", !Character.isLetter('9'));
1276:            }
1277:
1278:            /**
1279:             * @tests java.lang.Character#isLetter(int)
1280:             */
1281:            public void test_isLetter_I() {
1282:                assertTrue(Character.isLetter((int) 'L'));
1283:                assertFalse(Character.isLetter((int) '9'));
1284:
1285:                assertTrue(Character.isLetter(0x1FA9));
1286:                assertTrue(Character.isLetter(0x1D400));
1287:                assertTrue(Character.isLetter(0x1D622));
1288:                assertTrue(Character.isLetter(0x10000));
1289:
1290:                assertFalse(Character.isLetter(0x1012C));
1291:                assertFalse(Character.isLetter(0x110000));
1292:            }
1293:
1294:            /**
1295:             * @tests java.lang.Character#isLetterOrDigit(char)
1296:             */
1297:            public void test_isLetterOrDigitC() {
1298:                assertTrue("Digit returned false", Character
1299:                        .isLetterOrDigit('9'));
1300:                assertTrue("Letter returned false", Character
1301:                        .isLetterOrDigit('K'));
1302:                assertTrue("Control returned true", !Character
1303:                        .isLetterOrDigit('\n'));
1304:                assertTrue("Punctuation returned true", !Character
1305:                        .isLetterOrDigit('?'));
1306:            }
1307:
1308:            /**
1309:             * @tests java.lang.Character#isLetterOrDigit(int)
1310:             */
1311:            public void test_isLetterOrDigit_I() {
1312:                assertTrue(Character.isLetterOrDigit((int) '9'));
1313:                assertTrue(Character.isLetterOrDigit((int) 'K'));
1314:                assertFalse(Character.isLetterOrDigit((int) '\n'));
1315:                assertFalse(Character.isLetterOrDigit((int) '?'));
1316:
1317:                assertTrue(Character.isLetterOrDigit(0x1FA9));
1318:                assertTrue(Character.isLetterOrDigit(0x1D400));
1319:                assertTrue(Character.isLetterOrDigit(0x1D622));
1320:                assertTrue(Character.isLetterOrDigit(0x10000));
1321:
1322:                assertTrue(Character.isLetterOrDigit(0x1D7CE));
1323:                assertTrue(Character.isLetterOrDigit(0x1D7D8));
1324:
1325:                assertFalse(Character.isLetterOrDigit(0x10FFFD));
1326:                assertFalse(Character.isLetterOrDigit(0x1012C));
1327:                assertFalse(Character.isLetterOrDigit(0x110000));
1328:            }
1329:
1330:            /**
1331:             * @tests java.lang.Character#isLowerCase(char)
1332:             */
1333:            public void test_isLowerCaseC() {
1334:                assertTrue("lower returned false", Character.isLowerCase('a'));
1335:                assertTrue("upper returned true", !Character.isLowerCase('T'));
1336:            }
1337:
1338:            /**
1339:             * @tests java.lang.Character#isLowerCase(int)
1340:             */
1341:            public void test_isLowerCase_I() {
1342:                assertTrue(Character.isLowerCase((int) 'a'));
1343:                assertFalse(Character.isLowerCase((int) 'T'));
1344:
1345:                assertTrue(Character.isLowerCase(0x10428));
1346:                assertTrue(Character.isLowerCase(0x1D4EA));
1347:
1348:                assertFalse(Character.isLowerCase(0x1D504));
1349:                assertFalse(Character.isLowerCase(0x30000));
1350:                assertFalse(Character.isLowerCase(0x110000));
1351:            }
1352:
1353:            /**
1354:             * @tests java.lang.Character#isSpace(char)
1355:             */
1356:            @SuppressWarnings("deprecation")
1357:            public void test_isSpaceC() {
1358:                // Test for method boolean java.lang.Character.isSpace(char)
1359:                assertTrue("space returned false", Character.isSpace('\n'));
1360:                assertTrue("non-space returned true", !Character.isSpace('T'));
1361:            }
1362:
1363:            /**
1364:             * @tests java.lang.Character#isSpaceChar(char)
1365:             */
1366:            public void test_isSpaceCharC() {
1367:                assertTrue("space returned false", Character
1368:                        .isSpaceChar('\u0020'));
1369:                assertTrue("non-space returned true", !Character
1370:                        .isSpaceChar('\n'));
1371:            }
1372:
1373:            /**
1374:             * @tests java.lang.Character#isSpaceChar(int)
1375:             */
1376:            public void test_isSpaceChar_I() {
1377:                assertTrue(Character.isSpaceChar((int) '\u0020'));
1378:                assertFalse(Character.isSpaceChar((int) '\n'));
1379:
1380:                assertTrue(Character.isSpaceChar(0x2000));
1381:                assertTrue(Character.isSpaceChar(0x200A));
1382:
1383:                assertTrue(Character.isSpaceChar(0x2028));
1384:                assertTrue(Character.isSpaceChar(0x2029));
1385:
1386:                assertFalse(Character.isSpaceChar(0x110000));
1387:            }
1388:
1389:            /**
1390:             * @tests java.lang.Character#isTitleCase(char)
1391:             */
1392:            public void test_isTitleCaseC() {
1393:                char[] tChars = { (char) 0x01c5, (char) 0x01c8, (char) 0x01cb,
1394:                        (char) 0x01f2, (char) 0x1f88, (char) 0x1f89,
1395:                        (char) 0x1f8a, (char) 0x1f8b, (char) 0x1f8c,
1396:                        (char) 0x1f8d, (char) 0x1f8e, (char) 0x1f8f,
1397:                        (char) 0x1f98, (char) 0x1f99, (char) 0x1f9a,
1398:                        (char) 0x1f9b, (char) 0x1f9c, (char) 0x1f9d,
1399:                        (char) 0x1f9e, (char) 0x1f9f, (char) 0x1fa8,
1400:                        (char) 0x1fa9, (char) 0x1faa, (char) 0x1fab,
1401:                        (char) 0x1fac, (char) 0x1fad, (char) 0x1fae,
1402:                        (char) 0x1faf, (char) 0x1fbc, (char) 0x1fcc,
1403:                        (char) 0x1ffc };
1404:                byte tnum = 0;
1405:                for (char c = 0; c < 65535; c++) {
1406:                    if (Character.isTitleCase(c)) {
1407:                        tnum++;
1408:                        int i;
1409:                        for (i = 0; i < tChars.length; i++)
1410:                            if (tChars[i] == c)
1411:                                i = tChars.length + 1;
1412:                        if (i < tChars.length) {
1413:                            fail("Non Title Case char returned true");
1414:                        }
1415:                    }
1416:                }
1417:                assertTrue("Failed to find all Title Case chars",
1418:                        tnum == tChars.length);
1419:            }
1420:
1421:            /**
1422:             * @tests java.lang.Character#isTitleCase(int)
1423:             */
1424:            public void test_isTitleCase_I() {
1425:                //all the titlecase characters
1426:                int[] titleCaseCharacters = { 0x01c5, 0x01c8, 0x01cb, 0x01f2,
1427:                        0x1f88, 0x1f89, 0x1f8a, 0x1f8b, 0x1f8c, 0x1f8d, 0x1f8e,
1428:                        0x1f8f, 0x1f98, 0x1f99, 0x1f9a, 0x1f9b, 0x1f9c, 0x1f9d,
1429:                        0x1f9e, 0x1f9f, 0x1fa8, 0x1fa9, 0x1faa, 0x1fab, 0x1fac,
1430:                        0x1fad, 0x1fae, 0x1faf, 0x1fbc, 0x1fcc, 0x1ffc };
1431:
1432:                for (int i = 0; i < titleCaseCharacters.length; i++) {
1433:                    assertTrue(Character.isTitleCase(titleCaseCharacters[i]));
1434:                }
1435:
1436:                assertFalse(Character.isTitleCase(0x110000));
1437:            }
1438:
1439:            /**
1440:             * @tests java.lang.Character#isUnicodeIdentifierPart(char)
1441:             */
1442:            public void test_isUnicodeIdentifierPartC() {
1443:                assertTrue("'a' returned false", Character
1444:                        .isUnicodeIdentifierPart('a'));
1445:                assertTrue("'2' returned false", Character
1446:                        .isUnicodeIdentifierPart('2'));
1447:                assertTrue("'+' returned true", !Character
1448:                        .isUnicodeIdentifierPart('+'));
1449:            }
1450:
1451:            /**
1452:             * @tests java.lang.Character#isUnicodeIdentifierPart(int)
1453:             */
1454:            public void test_isUnicodeIdentifierPart_I() {
1455:                assertTrue(Character.isUnicodeIdentifierPart((int) 'a'));
1456:                assertTrue(Character.isUnicodeIdentifierPart((int) '2'));
1457:                assertFalse(Character.isUnicodeIdentifierPart((int) '+'));
1458:
1459:                assertTrue(Character.isUnicodeIdentifierPart(0x1FA9));
1460:                assertTrue(Character.isUnicodeIdentifierPart(0x1D400));
1461:                assertTrue(Character.isUnicodeIdentifierPart(0x1D622));
1462:                assertTrue(Character.isUnicodeIdentifierPart(0x10000));
1463:
1464:                assertTrue(Character.isUnicodeIdentifierPart(0x0030));
1465:                assertTrue(Character.isUnicodeIdentifierPart(0x0035));
1466:                assertTrue(Character.isUnicodeIdentifierPart(0x0039));
1467:
1468:                assertTrue(Character.isUnicodeIdentifierPart(0x0660));
1469:                assertTrue(Character.isUnicodeIdentifierPart(0x0665));
1470:                assertTrue(Character.isUnicodeIdentifierPart(0x0669));
1471:
1472:                assertTrue(Character.isUnicodeIdentifierPart(0x06F0));
1473:                assertTrue(Character.isUnicodeIdentifierPart(0x06F5));
1474:                assertTrue(Character.isUnicodeIdentifierPart(0x06F9));
1475:
1476:                assertTrue(Character.isUnicodeIdentifierPart(0x0966));
1477:                assertTrue(Character.isUnicodeIdentifierPart(0x096A));
1478:                assertTrue(Character.isUnicodeIdentifierPart(0x096F));
1479:
1480:                assertTrue(Character.isUnicodeIdentifierPart(0xFF10));
1481:                assertTrue(Character.isUnicodeIdentifierPart(0xFF15));
1482:                assertTrue(Character.isUnicodeIdentifierPart(0xFF19));
1483:
1484:                assertTrue(Character.isUnicodeIdentifierPart(0x1D7CE));
1485:                assertTrue(Character.isUnicodeIdentifierPart(0x1D7D8));
1486:
1487:                assertTrue(Character.isUnicodeIdentifierPart(0x16EE));
1488:                assertTrue(Character.isUnicodeIdentifierPart(0xFE33));
1489:                assertTrue(Character.isUnicodeIdentifierPart(0xFF10));
1490:                assertTrue(Character.isUnicodeIdentifierPart(0x1D165));
1491:                assertTrue(Character.isUnicodeIdentifierPart(0x1D167));
1492:                assertTrue(Character.isUnicodeIdentifierPart(0x1D173));
1493:
1494:                assertFalse(Character.isUnicodeIdentifierPart(0x10FFFF));
1495:                assertFalse(Character.isUnicodeIdentifierPart(0x110000));
1496:            }
1497:
1498:            /**
1499:             * @tests java.lang.Character#isUnicodeIdentifierStart(char)
1500:             */
1501:            public void test_isUnicodeIdentifierStartC() {
1502:                assertTrue("'a' returned false", Character
1503:                        .isUnicodeIdentifierStart('a'));
1504:                assertTrue("'2' returned true", !Character
1505:                        .isUnicodeIdentifierStart('2'));
1506:                assertTrue("'+' returned true", !Character
1507:                        .isUnicodeIdentifierStart('+'));
1508:            }
1509:
1510:            /**
1511:             * @tests java.lang.Character#isUnicodeIdentifierStart(int)
1512:             */
1513:            public void test_isUnicodeIdentifierStart_I() {
1514:
1515:                assertTrue(Character.isUnicodeIdentifierStart((int) 'a'));
1516:                assertFalse(Character.isUnicodeIdentifierStart((int) '2'));
1517:                assertFalse(Character.isUnicodeIdentifierStart((int) '+'));
1518:
1519:                assertTrue(Character.isUnicodeIdentifierStart(0x1FA9));
1520:                assertTrue(Character.isUnicodeIdentifierStart(0x1D400));
1521:                assertTrue(Character.isUnicodeIdentifierStart(0x1D622));
1522:                assertTrue(Character.isUnicodeIdentifierStart(0x10000));
1523:
1524:                assertTrue(Character.isUnicodeIdentifierStart(0x16EE));
1525:
1526:                // number is not a valid start of a Unicode identifier
1527:                assertFalse(Character.isUnicodeIdentifierStart(0x0030));
1528:                assertFalse(Character.isUnicodeIdentifierStart(0x0039));
1529:                assertFalse(Character.isUnicodeIdentifierStart(0x0660));
1530:                assertFalse(Character.isUnicodeIdentifierStart(0x0669));
1531:                assertFalse(Character.isUnicodeIdentifierStart(0x06F0));
1532:                assertFalse(Character.isUnicodeIdentifierStart(0x06F9));
1533:
1534:                assertFalse(Character.isUnicodeIdentifierPart(0x10FFFF));
1535:                assertFalse(Character.isUnicodeIdentifierPart(0x110000));
1536:            }
1537:
1538:            /**
1539:             * @tests java.lang.Character#isUpperCase(char)
1540:             */
1541:            public void test_isUpperCaseC() {
1542:                assertTrue("Incorrect case value", !Character.isUpperCase('t'));
1543:                assertTrue("Incorrect case value", Character.isUpperCase('T'));
1544:            }
1545:
1546:            /**
1547:             * @tests java.lang.Character#isUpperCase(int)
1548:             */
1549:            public void test_isUpperCase_I() {
1550:                assertFalse(Character.isUpperCase((int) 't'));
1551:                assertTrue(Character.isUpperCase((int) 'T'));
1552:
1553:                assertTrue(Character.isUpperCase(0x1D504));
1554:                assertTrue(Character.isUpperCase(0x1D608));
1555:
1556:                assertFalse(Character.isUpperCase(0x1D656));
1557:                assertFalse(Character.isUpperCase(0x10FFFD));
1558:                assertFalse(Character.isUpperCase(0x110000));
1559:            }
1560:
1561:            /**
1562:             * @tests java.lang.Character#isWhitespace(char)
1563:             */
1564:            public void test_isWhitespaceC() {
1565:                assertTrue("space returned false", Character.isWhitespace('\n'));
1566:                assertTrue("non-space returned true", !Character
1567:                        .isWhitespace('T'));
1568:            }
1569:
1570:            /**
1571:             * @tests java.lang.Character#isWhitespace(int)
1572:             */
1573:            public void test_isWhitespace_I() {
1574:                assertTrue(Character.isWhitespace((int) '\n'));
1575:                assertFalse(Character.isWhitespace((int) 'T'));
1576:
1577:                assertTrue(Character.isWhitespace(0x0009));
1578:                assertTrue(Character.isWhitespace(0x000A));
1579:                assertTrue(Character.isWhitespace(0x000B));
1580:                assertTrue(Character.isWhitespace(0x000C));
1581:                assertTrue(Character.isWhitespace(0x000D));
1582:                assertTrue(Character.isWhitespace(0x001C));
1583:                assertTrue(Character.isWhitespace(0x001D));
1584:                assertTrue(Character.isWhitespace(0x001F));
1585:                assertTrue(Character.isWhitespace(0x001E));
1586:
1587:                assertTrue(Character.isWhitespace(0x2000));
1588:                assertTrue(Character.isWhitespace(0x200A));
1589:
1590:                assertTrue(Character.isWhitespace(0x2028));
1591:                assertTrue(Character.isWhitespace(0x2029));
1592:
1593:                assertFalse(Character.isWhitespace(0x00A0));
1594:                assertFalse(Character.isWhitespace(0x202F));
1595:                assertFalse(Character.isWhitespace(0x110000));
1596:
1597:                assertFalse(Character.isWhitespace(0xFEFF));
1598:
1599:                //FIXME depend on ICU4J
1600:                //assertFalse(Character.isWhitespace(0x2007));
1601:
1602:            }
1603:
1604:            /**
1605:             * @tests java.lang.Character#reverseBytes(char)
1606:             */
1607:            public void test_reverseBytesC() {
1608:                char original[] = new char[] { 0x0000, 0x0010, 0x00AA, 0xB000,
1609:                        0xCC00, 0xABCD, 0xFFAA };
1610:                char reversed[] = new char[] { 0x0000, 0x1000, 0xAA00, 0x00B0,
1611:                        0x00CC, 0xCDAB, 0xAAFF };
1612:                assertTrue("Test self check",
1613:                        original.length == reversed.length);
1614:
1615:                for (int i = 0; i < original.length; i++) {
1616:                    char origChar = original[i];
1617:                    char reversedChar = reversed[i];
1618:                    char origReversed = Character.reverseBytes(origChar);
1619:
1620:                    assertTrue(
1621:                            "java.lang.Character.reverseBytes failed: orig char="
1622:                                    + Integer.toHexString(origChar)
1623:                                    + ", reversed char="
1624:                                    + Integer.toHexString(origReversed),
1625:                            reversedChar == origReversed);
1626:                }
1627:            }
1628:
1629:            /**
1630:             * @tests java.lang.Character#toLowerCase(char)
1631:             */
1632:            public void test_toLowerCaseC() {
1633:                assertEquals("Failed to change case", 't', Character
1634:                        .toLowerCase('T'));
1635:            }
1636:
1637:            /**
1638:             * @tests java.lang.Character#toLowerCase(int)
1639:             */
1640:            public void test_toLowerCase_I() {
1641:                assertEquals('t', Character.toLowerCase((int) 'T'));
1642:
1643:                assertEquals(0x10428, Character.toLowerCase(0x10400));
1644:                assertEquals(0x10428, Character.toLowerCase(0x10428));
1645:
1646:                assertEquals(0x1D504, Character.toLowerCase(0x1D504));
1647:                assertEquals(0x10FFFD, Character.toLowerCase(0x10FFFD));
1648:                assertEquals(0x110000, Character.toLowerCase(0x110000));
1649:            }
1650:
1651:            /**
1652:             * @tests java.lang.Character#toString()
1653:             */
1654:            public void test_toString() {
1655:                assertEquals("Incorrect String returned", "T", new Character(
1656:                        'T').toString());
1657:            }
1658:
1659:            /**
1660:             * @tests java.lang.Character#toTitleCase(char)
1661:             */
1662:            public void test_toTitleCaseC() {
1663:                assertEquals("Incorrect title case for a", 'A', Character
1664:                        .toTitleCase('a'));
1665:                assertEquals("Incorrect title case for A", 'A', Character
1666:                        .toTitleCase('A'));
1667:                assertEquals("Incorrect title case for 1", '1', Character
1668:                        .toTitleCase('1'));
1669:            }
1670:
1671:            /**
1672:             * @tests java.lang.Character#toTitleCase(int)
1673:             */
1674:            public void test_toTitleCase_I() {
1675:                assertEquals('A', Character.toTitleCase((int) 'a'));
1676:                assertEquals('A', Character.toTitleCase((int) 'A'));
1677:                assertEquals('1', Character.toTitleCase((int) '1'));
1678:
1679:                assertEquals(0x10400, Character.toTitleCase(0x10428));
1680:                assertEquals(0x10400, Character.toTitleCase(0x10400));
1681:
1682:                assertEquals(0x10FFFF, Character.toTitleCase(0x10FFFF));
1683:                assertEquals(0x110000, Character.toTitleCase(0x110000));
1684:            }
1685:
1686:            /**
1687:             * @tests java.lang.Character#toUpperCase(char)
1688:             */
1689:            public void test_toUpperCaseC() {
1690:                // Test for method char java.lang.Character.toUpperCase(char)
1691:                assertEquals("Incorrect upper case for a", 'A', Character
1692:                        .toUpperCase('a'));
1693:                assertEquals("Incorrect upper case for A", 'A', Character
1694:                        .toUpperCase('A'));
1695:                assertEquals("Incorrect upper case for 1", '1', Character
1696:                        .toUpperCase('1'));
1697:            }
1698:
1699:            /**
1700:             * @tests java.lang.Character#toUpperCase(int)
1701:             */
1702:            public void test_toUpperCase_I() {
1703:                assertEquals('A', Character.toUpperCase((int) 'a'));
1704:                assertEquals('A', Character.toUpperCase((int) 'A'));
1705:                assertEquals('1', Character.toUpperCase((int) '1'));
1706:
1707:                assertEquals(0x10400, Character.toUpperCase(0x10428));
1708:                assertEquals(0x10400, Character.toUpperCase(0x10400));
1709:
1710:                assertEquals(0x10FFFF, Character.toUpperCase(0x10FFFF));
1711:                assertEquals(0x110000, Character.toUpperCase(0x110000));
1712:            }
1713:
1714:            /**
1715:             * @tests java.lang.Character#getDirectionality(int)
1716:             */
1717:            public void test_isDirectionaliy_I() {
1718:                assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character
1719:                        .getDirectionality(0xFFFE));
1720:                assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character
1721:                        .getDirectionality(0x30000));
1722:                assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character
1723:                        .getDirectionality(0x110000));
1724:                assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character
1725:                        .getDirectionality(-1));
1726:
1727:                assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character
1728:                        .getDirectionality(0x0041));
1729:                assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character
1730:                        .getDirectionality(0x10000));
1731:                assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character
1732:                        .getDirectionality(0x104A9));
1733:
1734:                assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT, Character
1735:                        .getDirectionality(0xFB4F));
1736:                assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT, Character
1737:                        .getDirectionality(0x10838));
1738:
1739:                assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC,
1740:                        Character.getDirectionality(0x0600));
1741:                assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC,
1742:                        Character.getDirectionality(0xFEFC));
1743:
1744:                assertEquals(Character.DIRECTIONALITY_EUROPEAN_NUMBER,
1745:                        Character.getDirectionality(0x2070));
1746:                assertEquals(Character.DIRECTIONALITY_EUROPEAN_NUMBER,
1747:                        Character.getDirectionality(0x1D7FF));
1748:
1749:                //RI fails ,this is non-bug difference between Unicode 4.0 and 4.1
1750:                assertEquals(
1751:                        Character.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR,
1752:                        Character.getDirectionality(0x002B));
1753:                assertEquals(
1754:                        Character.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR,
1755:                        Character.getDirectionality(0xFF0B));
1756:
1757:                assertEquals(
1758:                        Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR,
1759:                        Character.getDirectionality(0x0023));
1760:                assertEquals(
1761:                        Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR,
1762:                        Character.getDirectionality(0x17DB));
1763:
1764:                assertEquals(Character.DIRECTIONALITY_ARABIC_NUMBER, Character
1765:                        .getDirectionality(0x0660));
1766:                assertEquals(Character.DIRECTIONALITY_ARABIC_NUMBER, Character
1767:                        .getDirectionality(0x066C));
1768:
1769:                assertEquals(Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR,
1770:                        Character.getDirectionality(0x002C));
1771:                assertEquals(Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR,
1772:                        Character.getDirectionality(0xFF1A));
1773:
1774:                assertEquals(Character.DIRECTIONALITY_NONSPACING_MARK,
1775:                        Character.getDirectionality(0x17CE));
1776:                assertEquals(Character.DIRECTIONALITY_NONSPACING_MARK,
1777:                        Character.getDirectionality(0xE01DB));
1778:
1779:                assertEquals(Character.DIRECTIONALITY_BOUNDARY_NEUTRAL,
1780:                        Character.getDirectionality(0x0000));
1781:                assertEquals(Character.DIRECTIONALITY_BOUNDARY_NEUTRAL,
1782:                        Character.getDirectionality(0xE007F));
1783:
1784:                assertEquals(Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR,
1785:                        Character.getDirectionality(0x000A));
1786:                assertEquals(Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR,
1787:                        Character.getDirectionality(0x2029));
1788:
1789:                assertEquals(Character.DIRECTIONALITY_SEGMENT_SEPARATOR,
1790:                        Character.getDirectionality(0x0009));
1791:                assertEquals(Character.DIRECTIONALITY_SEGMENT_SEPARATOR,
1792:                        Character.getDirectionality(0x001F));
1793:
1794:                assertEquals(Character.DIRECTIONALITY_WHITESPACE, Character
1795:                        .getDirectionality(0x0020));
1796:                assertEquals(Character.DIRECTIONALITY_WHITESPACE, Character
1797:                        .getDirectionality(0x3000));
1798:
1799:                assertEquals(Character.DIRECTIONALITY_OTHER_NEUTRALS, Character
1800:                        .getDirectionality(0x2FF0));
1801:                assertEquals(Character.DIRECTIONALITY_OTHER_NEUTRALS, Character
1802:                        .getDirectionality(0x1D356));
1803:
1804:                assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING,
1805:                        Character.getDirectionality(0x202A));
1806:
1807:                assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE,
1808:                        Character.getDirectionality(0x202D));
1809:
1810:                assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING,
1811:                        Character.getDirectionality(0x202B));
1812:
1813:                assertEquals(Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE,
1814:                        Character.getDirectionality(0x202E));
1815:
1816:                assertEquals(Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT,
1817:                        Character.getDirectionality(0x202C));
1818:            }
1819:        }
w__w_w__.j__av__a_2s___.co___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.