Package java.text

Examples of java.text.ChoiceFormat.applyPattern()


      harness.check (doformat (cf, 1.5, buf), "Sun");
      harness.check (doformat (cf, 5.5, buf), "Thu");
      harness.check (doformat (cf, 7.0, buf), "Sat");
      harness.check (doformat (cf, 99.5, buf), "Sat");

      cf.applyPattern ("-1.0#Less than one|1.0#One|1.0<One to two, exclusive|2.0#Two to three, inclusive|3.0<Over three, up to four|4.0<Four to five, exclusive|5.0#Five and above");
      harness.check (doformat (cf, -23, buf), "Less than one");
      harness.check (doformat (cf, -.5, buf), "Less than one");
      harness.check (doformat (cf, ChoiceFormat.previousDouble (1.0), buf),
         "Less than one");
      harness.check (doformat (cf, 1.0, buf), "One");
View Full Code Here


     */
    public void test_applyPatternLjava_lang_String() {
        // Test for method void
        // java.text.ChoiceFormat.applyPattern(java.lang.String)
        ChoiceFormat f = (ChoiceFormat) f1.clone();
        f.applyPattern("0#0|1#1");
        assertTrue("Incorrect limits", java.util.Arrays.equals(f.getLimits(),
                new double[] { 0, 1 }));
        assertTrue("Incorrect formats", java.util.Arrays.equals(f.getFormats(),
                new String[] { "0", "1" }));
       
View Full Code Here

        double[] choiceLimits = { -1, 0, 1, ChoiceFormat.nextDouble(1) };
        String[] choiceFormats = { "is negative", "is zero or fraction",
                "is one", "is more than 1" };
       
        f = new ChoiceFormat("");
        f.applyPattern("-1#is negative|0#is zero or fraction|1#is one|1<is more than 1");
        assertTrue("Incorrect limits", java.util.Arrays.equals(f.getLimits(),
                choiceLimits));
        assertTrue("Incorrect formats", java.util.Arrays.equals(f.getFormats(),
                choiceFormats));
       
View Full Code Here

        assertTrue("Incorrect formats", java.util.Arrays.equals(f.getFormats(),
                choiceFormats));
       
        f = new ChoiceFormat("");
        try {
            f.applyPattern("-1#is negative|0#is zero or fraction|-1#is one|1<is more than 1");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // Expected
        }
       
View Full Code Here

            // Expected
        }
       
        f = new ChoiceFormat("");
        try {
            f.applyPattern("-1is negative|0#is zero or fraction|1#is one|1<is more than 1");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // Expected
        }
       
View Full Code Here

        } catch (IllegalArgumentException e) {
            // Expected
        }
       
        f = new ChoiceFormat("");
        f.applyPattern("-1<is negative|0#is zero or fraction|1#is one|1<is more than 1");
        choiceLimits[0] = ChoiceFormat.nextDouble(-1);
        assertTrue("Incorrect limits", java.util.Arrays.equals(f.getLimits(),
                choiceLimits));
        assertTrue("Incorrect formats", java.util.Arrays.equals(f.getFormats(),
                choiceFormats));
View Full Code Here

                choiceLimits));
        assertTrue("Incorrect formats", java.util.Arrays.equals(f.getFormats(),
                choiceFormats));
       
        f = new ChoiceFormat("");
        f.applyPattern("-1#is negative|0#is zero or fraction|1#is one|1<is more than 1");
        String str = "org.apache.harmony.tests.java.text.ChoiceFormat";
        f.applyPattern(str);
        String ptrn = f.toPattern();
        assertEquals("Return value should be empty string for invalid pattern",
                0, ptrn.length());
View Full Code Here

                choiceFormats));
       
        f = new ChoiceFormat("");
        f.applyPattern("-1#is negative|0#is zero or fraction|1#is one|1<is more than 1");
        String str = "org.apache.harmony.tests.java.text.ChoiceFormat";
        f.applyPattern(str);
        String ptrn = f.toPattern();
        assertEquals("Return value should be empty string for invalid pattern",
                0, ptrn.length());
    }
View Full Code Here

                        .equals("0.0#Less than one|1.0#one|1.0<Between one and two|2.0<Greater than two"));

        cf = new ChoiceFormat(
                "-1#is negative| 0#is zero or fraction | 1#is one |1.0<is 1+|2#is two |2<is more than 2.");
        String str = "org.apache.harmony.tests.java.lang.share.MyResources2";
        cf.applyPattern(str);
        ptrn = cf.toPattern();
    assertEquals("Return value should be empty string for invalid pattern",
        0, ptrn.length());
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.