harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "lcj.dev" <lcj....@gmail.com>
Subject Question about Character.valueOf()
Date Tue, 16 Nov 2010 13:44:33 GMT
Hi, all
Why this may be failed for other JREs? assertSame(Character.valueOf(c), Character.valueOf(c)).
Thanks.

please refers to this test case for details:
package org.apache.harmony.luni.tests.java.lang;

import junit.framework.TestCase;

public class CharacterImplTest extends TestCase {

    public void test_valueOfC() {
        // test the cache range
        for (char c = '\u0000'; c < 512; c++) {
            Character e = new Character(c);
            Character a = Character.valueOf(c);
            assertEquals(e, a);

            // WARN: this assertion may not be valid on other JREs
            assertSame(Character.valueOf(c), Character.valueOf(c));
        }
        // test the rest of the chars
        for (int c = '\u0512'; c <= Character.MAX_VALUE; c++) {
            assertEquals(new Character((char) c), Character.valueOf((char) c));
        }
    }
}
2010-11-16



lcj.dev
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message