CharacterImplTest.java revision f6c387128427e121477c1b32ad35cdcaa5101ba3
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.AndroidOnly;
20import dalvik.annotation.TestTargets;
21import dalvik.annotation.TestLevel;
22import dalvik.annotation.TestTargetNew;
23import dalvik.annotation.TestTargetClass;
24
25import junit.framework.TestCase;
26
27@TestTargetClass(Character.class)
28public class CharacterImplTest extends TestCase {
29
30    @TestTargetNew(
31        level = TestLevel.COMPLETE,
32        notes = "",
33        method = "valueOf",
34        args = {char.class}
35    )
36    @AndroidOnly("valueOf doesn't return the same values on RI.")
37    public void test_valueOfC() {
38        // test the cache range
39        for (char c = '\u0000'; c < 512; c++) {
40            Character e = new Character(c);
41            Character a = Character.valueOf(c);
42            assertEquals(e, a);
43
44            // WARN: this assertion may not be valid on other JREs
45            assertSame(Character.valueOf(c), Character.valueOf(c));
46        }
47        // test the rest of the chars
48        for (int c = '\u0512'; c <= Character.MAX_VALUE; c++) {
49            assertEquals(new Character((char) c), Character.valueOf((char) c));
50        }
51    }
52}
53