Java 类java.lang.Character.UnicodeScript 实例源码

项目:sol    文件:ProximityMapTest.java   
@Test
public void validateRoundDown() {
    ProximityMap<UnicodeScript> prox = new ProximityMap<UnicodeScript>();

    putAll(prox, Arrays.asList(javanese, greek, gothic, latin));

    validate(prox, -43, javanese);
    validate(prox, -42, javanese);
    validate(prox, -41, javanese);
    validate(prox, -33, javanese);
    validate(prox, -32, javanese);
    validate(prox, -31, greek);
    validate(prox, -23, greek);
    validate(prox, -22, greek);
    validate(prox, -21, greek);
    validate(prox, -12, greek);
    validate(prox, -11, greek);
    validate(prox, -10, latin);
    validate(prox, -1, latin);
    validate(prox, 0, latin);
    validate(prox, 1, latin);
    validate(prox, 10, latin);
    validate(prox, 11, latin);
    validate(prox, 12, gothic);
    validate(prox, 21, gothic);
    validate(prox, 22, gothic);
    validate(prox, 23, gothic);
}
项目:sol    文件:ProximityMapTest.java   
@Test
public void validateRoundUp() {
    ProximityMap<UnicodeScript> prox = new ProximityMap<UnicodeScript>(Round.UP);

    putAll(prox, Arrays.asList(javanese, greek, gothic, latin));

    validate(prox, -43, javanese);
    validate(prox, -42, javanese);
    validate(prox, -41, javanese);
    validate(prox, -33, javanese);
    validate(prox, -32, greek);
    validate(prox, -31, greek);
    validate(prox, -23, greek);
    validate(prox, -22, greek);
    validate(prox, -21, greek);
    validate(prox, -12, greek);
    validate(prox, -11, latin);
    validate(prox, -10, latin);
    validate(prox, -1, latin);
    validate(prox, 0, latin);
    validate(prox, 1, latin);
    validate(prox, 10, latin);
    validate(prox, 11, gothic);
    validate(prox, 12, gothic);
    validate(prox, 21, gothic);
    validate(prox, 22, gothic);
    validate(prox, 23, gothic);
}
项目:sol    文件:ProximityMapTest.java   
@Test
public void validateSingle() {
    ProximityMap<UnicodeScript> prox = new ProximityMap<UnicodeScript>();

    putAll(prox, Arrays.asList(javanese));

    validate(prox, -1000, javanese);
    validate(prox, -43, javanese);
    validate(prox, -42, javanese);
    validate(prox, 1000, javanese);
}
项目:sol    文件:ProximityMapTest.java   
@Test
public void validateEmpty() {
    ProximityMap<UnicodeScript> prox = new ProximityMap<UnicodeScript>();

    validate(prox, -1000, null);
    validate(prox, 1000, null);
}
项目:sol    文件:ProximityMapTest.java   
private static void validate(ProximityMap<UnicodeScript> prox, int pos, Pair<BigDecimal, UnicodeScript> expected) {
    BigDecimal key = new BigDecimal(pos);
    if (expected == null) {
        assertNull(prox.closestEntry(key));
        assertNull(prox.closestKey(key));
        assertNull(prox.closestValue(key));
    } else {
        assertEquals(expected.getX(), prox.closestEntry(key).getKey());
        assertEquals(expected.getX(), prox.closestKey(key));
        assertEquals(expected.getY(), prox.closestEntry(key).getValue());
        assertEquals(expected.getY(), prox.closestValue(key));
    }
}