java.util.Locale#CANADA源码实例Demo

下面列出了java.util.Locale#CANADA 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: sis   文件: RangeFormatTest.java
/**
 * Tests the parsing method on ranges of numbers. This test fixes the type to
 * {@code Integer.class}.  A different test will let the parser determine the
 * type itself.
 */
@Test
public void testParseIntegers() {
    format   = new RangeFormat(Locale.CANADA, Integer.class);
    parsePos = new ParsePosition(0);

    assertEquals(NumberRange.create(-10, true,   20, true ), parse("[-10 … 20]" ));
    assertEquals(NumberRange.create( -3, false,   4, false), parse("( -3 …  4) "));
    assertEquals(NumberRange.create(  2, true,    8, false), parse("  [2 …  8) "));
    assertEquals(NumberRange.create( 40, false,  90, true ), parse(" (40 … 90]"));
    assertEquals(NumberRange.create(300, true,  300, true ), parse(" 300 "));
    assertEquals(NumberRange.create(300, true,  300, true ), parse("[300]"));
    assertEquals(NumberRange.create(300, false, 300, false), parse("(300)"));
    assertEquals(NumberRange.create(300, true,  300, true ), parse("{300}"));
    assertEquals(NumberRange.create(  0, true,    0, false), parse("[]"));
    assertEquals(NumberRange.create(  0, true,    0, false), parse("{}"));
}
 
源代码2 项目: j2objc   文件: DecimalFormatTest.java
public void test_setCurrency() {
    Locale locale = Locale.CANADA;
    DecimalFormat df = ((DecimalFormat) NumberFormat.getCurrencyInstance(locale));

    try {
        df.setCurrency(null);
        fail("Expected NullPointerException");
    } catch (NullPointerException e) {
    }

    Currency currency = Currency.getInstance("AED");
    df.setCurrency(currency);
    assertTrue("Returned incorrect currency", currency == df.getCurrency());
    assertEquals("Returned incorrect currency symbol", currency.getSymbol(locale),
            df.getDecimalFormatSymbols().getCurrencySymbol());
    assertEquals("Returned incorrect international currency symbol", currency.getCurrencyCode(),
            df.getDecimalFormatSymbols().getInternationalCurrencySymbol());
}
 
源代码3 项目: j2objc   文件: DecimalFormatSymbolsTest.java
/**
 * @tests java.text.DecimalFormatSymbols#setCurrency(java.util.Currency)
 */
public void test_setCurrencyLjava_util_Currency() {
    Locale locale = Locale.CANADA;
    DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
            .getCurrencyInstance(locale)).getDecimalFormatSymbols();

    try {
        dfs.setCurrency(null);
        fail("Expected NullPointerException");
    } catch (NullPointerException e) {
    }

    Currency currency = Currency.getInstance("JPY");
    dfs.setCurrency(currency);

    assertTrue("Returned incorrect currency", currency == dfs.getCurrency());
    assertEquals("Returned incorrect currency symbol", currency.getSymbol(
            locale), dfs.getCurrencySymbol());
    assertTrue("Returned incorrect international currency symbol", currency
            .getCurrencyCode().equals(dfs.getInternationalCurrencySymbol()));
}
 
源代码4 项目: sis   文件: AngleFormatTest.java
/**
 * Tests the field position while formatting an angle.
 */
@Test
public void testFieldPosition() {
    final Latitude latitude = new Latitude(FormattedCharacterIteratorTest.LATITUDE_VALUE);
    final AngleFormat f = new AngleFormat("DD°MM′SS.s″", Locale.CANADA);
    final StringBuffer buffer = new StringBuffer();
    for (int i=AngleFormat.DEGREES_FIELD; i<=AngleFormat.HEMISPHERE_FIELD; i++) {
        final AngleFormat.Field field;
        final int start, limit;
        switch (i) {
            case AngleFormat.DEGREES_FIELD:    field = AngleFormat.Field.DEGREES;    start= 0; limit= 3;  break;
            case AngleFormat.MINUTES_FIELD:    field = AngleFormat.Field.MINUTES;    start= 3; limit= 6;  break;
            case AngleFormat.SECONDS_FIELD:    field = AngleFormat.Field.SECONDS;    start= 6; limit=11; break;
            case AngleFormat.HEMISPHERE_FIELD: field = AngleFormat.Field.HEMISPHERE; start=11; limit=12; break;
            default: continue; // Skip the fraction field.
        }
        final FieldPosition pos = new FieldPosition(field);
        assertEquals(FormattedCharacterIteratorTest.LATITUDE_STRING, f.format(latitude, buffer, pos).toString());
        assertSame  ("getFieldAttribute", field, pos.getFieldAttribute());
        assertEquals("getBeginIndex",     start, pos.getBeginIndex());
        assertEquals("getEndIndex",       limit, pos.getEndIndex());
        buffer.setLength(0);
    }
}
 
源代码5 项目: sis   文件: AngleFormatTest.java
/**
 * Tests values that have to be rounded, especially the values near zero.
 */
@Test
@DependsOnMethod("testDegreeMinutesSeconds")
public void testRounding() {
    final AngleFormat f = new AngleFormat("DD°MM′SS.sss″", Locale.CANADA);
    assertEquals( "01°00′00.000″", f.format(new Angle(+(59 + (59.9999 / 60)) / 60)));
    assertEquals("-01°00′00.000″", f.format(new Angle(-(59 + (59.9999 / 60)) / 60)));
    assertEquals("-00°59′59.999″", f.format(new Angle(-(59 + (59.9988 / 60)) / 60)));
}
 
源代码6 项目: flow   文件: ValueContextTest.java
@Test
public void testHasValue3() {
    setLocale(Locale.getDefault());
    ValueContext fromComponent = new ValueContext(new TestDatePicker(),
            textField, Locale.CANADA);
    Assert.assertEquals(textField, fromComponent.getHasValue().get());
    Assert.assertEquals(Locale.CANADA, fromComponent.getLocale().get());
}
 
源代码7 项目: spring-data-crate   文件: SimpleEntity.java
public static SimpleEntity simpleEntity() {
	
	SimpleEntity entity = new SimpleEntity();
	entity.boolField = true;
   	entity.dateField = new Date();
   	entity.localeField = Locale.CANADA;
   	entity.stringField= "CRATE";
   	
   	return entity;
}
 
源代码8 项目: j2objc   文件: AlphabeticIndexTest.java
@Test
public void testAddLabels_Locale() {
    AlphabeticIndex<?> ulocaleIndex = new AlphabeticIndex<String>(ULocale.CANADA);
    AlphabeticIndex<?> localeIndex = new AlphabeticIndex<String>(Locale.CANADA);
    ulocaleIndex.addLabels(ULocale.SIMPLIFIED_CHINESE);
    localeIndex.addLabels(Locale.SIMPLIFIED_CHINESE);
    assertEquals("getBucketLables() results of ulocaleIndex and localeIndex differ",
            ulocaleIndex.getBucketLabels(), localeIndex.getBucketLabels());
}
 
源代码9 项目: j2objc   文件: FormatterTest.java
/**
 * java.util.Formatter#Formatter(Appendable, Locale)
 */
public void test_ConstructorLjava_lang_AppendableLjava_util_Locale() {
    MockAppendable ma = new MockAppendable();
    Formatter f1 = new Formatter(ma, Locale.CANADA);
    assertEquals(ma, f1.out());
    assertEquals(f1.locale(), Locale.CANADA);

    Formatter f2 = new Formatter(ma, null);
    assertNull(f2.locale());
    assertEquals(ma, f1.out());

    Formatter f3 = new Formatter(null, Locale.GERMAN);
    assertEquals(f3.locale(), Locale.GERMAN);
    assertTrue(f3.out() instanceof StringBuilder);
}
 
源代码10 项目: pdfsam   文件: LocaleKeyValueItemTest.java
@Test
public void equalsAndHashCodes() {
    LocaleKeyValueItem eq1 = new LocaleKeyValueItem(Locale.CANADA);
    LocaleKeyValueItem eq2 = new LocaleKeyValueItem(Locale.CANADA);
    LocaleKeyValueItem eq3 = new LocaleKeyValueItem(Locale.CANADA);
    LocaleKeyValueItem diff = new LocaleKeyValueItem(Locale.CHINA);
    TestUtils.testEqualsAndHashCodes(eq1, eq2, eq3, diff);
}
 
源代码11 项目: sis   文件: CoordinateFormatTest.java
/**
 * Tests parsing from a position different then the beginning of the string.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
public void testParseFromOffset() throws ParseException {
    CoordinateFormat coordinateFormat = new CoordinateFormat(Locale.CANADA, null);
    coordinateFormat.setDefaultCRS(VerticalCRSMock.BAROMETRIC_HEIGHT);
    ParsePosition  charPos  = new ParsePosition(7);
    DirectPosition position = coordinateFormat.parse("[skip] 12", charPos);
    assertEquals("Should have parsed the whole text.", 9, charPos.getIndex());
    assertEquals("DirectPosition.getDimension()", 1, position.getDimension());
    assertArrayEquals(new double[] {12}, position.getCoordinate(), STRICT);
}
 
源代码12 项目: sis   文件: CoordinateFormatTest.java
/**
 * Tests {@link CoordinateFormat#clone()}, then verifies that the clone has the same configuration
 * than the original object.
 */
@Test
public void testClone() {
    CoordinateFormat format = new CoordinateFormat(Locale.CANADA, null);
    CoordinateFormat clone  = format.clone();
    assertNotSame("clone()", clone, format);
    assertEquals("getSeparator()",  format.getSeparator(),  clone.getSeparator());
    assertEquals("getDefaultCRS()", format.getDefaultCRS(), clone.getDefaultCRS());
}
 
源代码13 项目: sis   文件: AngleFormatTest.java
/**
 * Tests using {@link Locale#CANADA}.
 */
@Test
public void testCanadaLocale() {
    final AngleFormat f = new AngleFormat("DD.ddd°", Locale.CANADA);
    assertEquals(3, f.getMinimumFractionDigits());
    assertEquals(3, f.getMaximumFractionDigits());
    assertEquals( "DD.ddd°",  f.toPattern());
    assertEquals( "20.000°",  formatAndParse(f, new Angle   ( 20.000)));
    assertEquals( "20.749°",  formatAndParse(f, new Angle   ( 20.749)));
    assertEquals("-12.247°",  formatAndParse(f, new Angle   (-12.247)));
    assertEquals( "13.214°N", formatAndParse(f, new Latitude( 13.214)));
    assertEquals( "12.782°S", formatAndParse(f, new Latitude(-12.782)));
    assertEquals("-00.010°",  formatAndParse(f, new Angle   (-0.01)));
}
 
源代码14 项目: sis   文件: AngleFormatTest.java
/**
 * Tests with no decimal separator.
 */
@Test
public void testNoSeparator() {
    final AngleFormat f = new AngleFormat("DDddd", Locale.CANADA);
    assertEquals(3, f.getMinimumFractionDigits());
    assertEquals(3, f.getMaximumFractionDigits());
    assertEquals( "DDddd",  f.toPattern());
    assertEquals( "19457E", formatAndParse(f, new Longitude( 19.457)));
    assertEquals( "78124S", formatAndParse(f, new Latitude (-78.124)));
    assertEquals("-00010",  formatAndParse(f, new Angle    (-0.01)));
}
 
源代码15 项目: sis   文件: RangeFormatTest.java
/**
 * Tests the parsing method on ranges of numbers where the type is inferred automatically.
 */
@Test
@SuppressWarnings("cast")
public void testParseAuto() {
    format   = new RangeFormat(Locale.CANADA);
    parsePos = new ParsePosition(0);

    assertEquals(NumberRange.create((byte)    -10, true, (byte)    20, true), parse("[  -10 …    20]" ));
    assertEquals(NumberRange.create((short) -1000, true, (short) 2000, true), parse("[-1000 …  2000]" ));
    assertEquals(NumberRange.create((int)      10, true, (int)  40000, true), parse("[   10 … 40000]" ));
    assertEquals(NumberRange.create((int)       1, true, (int)  50000, true), parse("[ 1.00 … 50000]" ));
    assertEquals(NumberRange.create((float)   8.5, true, (float)    4, true), parse("[ 8.50 …     4]" ));
}
 
源代码16 项目: jphp   文件: WrapLocale.java
@Signature
public static Memory CANADA(Environment env, Memory... args) {
    return new ObjectMemory(new WrapLocale(env, Locale.CANADA));
}
 
源代码17 项目: sis   文件: AngleFormatTest.java
/**
 * Tests a pattern with illegal usage of D, M and S symbols.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalPattern() {
    final AngleFormat f = new AngleFormat(Locale.CANADA);
    f.applyPattern("DD°SS′MM″");
}
 
源代码18 项目: sis   文件: AngleFormatTest.java
/**
 * Tests an illegal pattern with illegal symbols for the fraction part.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalFractionPattern() {
    final AngleFormat f = new AngleFormat(Locale.CANADA);
    f.applyPattern("DD°MM′SS.m″");
}
 
源代码19 项目: sis   文件: AngleFormatTest.java
/**
 * Tests a {@code '?'} symbol without suffix.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalOptionalField() {
    final AngleFormat f = new AngleFormat(Locale.CANADA);
    f.applyPattern("DD°MM?SS.m″");
}
 
源代码20 项目: sis   文件: AngleFormatTest.java
/**
 * Tests a {@code '?'} symbol without suffix.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalOptionalLastField() {
    final AngleFormat f = new AngleFormat(Locale.CANADA);
    f.applyPattern("DD°MM?");
}