CharacterImplTest.java revision cc05ad238516f1303687aba4a978e24e57c0c07a
1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. 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 org.apache.harmony.luni.tests.java.lang; 18 19import dalvik.annotation.TestTargets; 20import dalvik.annotation.TestLevel; 21import dalvik.annotation.TestTargetNew; 22import dalvik.annotation.TestTargetClass; 23 24import junit.framework.TestCase; 25 26@TestTargetClass(Character.class) 27public class CharacterImplTest extends TestCase { 28 29 @TestTargetNew( 30 level = TestLevel.COMPLETE, 31 notes = "", 32 method = "valueOf", 33 args = {char.class} 34 ) 35 public void test_valueOfC() { 36 // test the cache range 37 for (char c = '\u0000'; c < 512; c++) { 38 Character e = new Character(c); 39 Character a = Character.valueOf(c); 40 assertEquals(e, a); 41 42 // WARN: this assertion may not be valid on other JREs 43 assertEquals(Character.valueOf(c), Character.valueOf(c)); 44 } 45 // test the rest of the chars 46 for (int c = '\u0512'; c <= Character.MAX_VALUE; c++) { 47 assertEquals(new Character((char) c), Character.valueOf((char) c)); 48 } 49 } 50} 51