CharacterTest.java revision 4557728efb66c455a52b7669a8eefef7a9e54854
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package libcore.java.lang; 18 19public class CharacterTest extends junit.framework.TestCase { 20 public void test_valueOfC() { 21 // The JLS requires caching for chars between "\u0000 to \u007f": 22 // http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7 23 // Harmony caches 0-512 and tests for this behavior, so we suppress that test and use this. 24 for (char c = '\u0000'; c <= '\u007f'; ++c) { 25 Character e = new Character(c); 26 Character a = Character.valueOf(c); 27 assertEquals(e, a); 28 assertSame(Character.valueOf(c), Character.valueOf(c)); 29 } 30 for (int c = '\u0080'; c <= Character.MAX_VALUE; ++c) { 31 assertEquals(new Character((char) c), Character.valueOf((char) c)); 32 } 33 } 34} 35