use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestGetDecimal.
/* Tests the method
* public String getDecimal()
*/
@Test
public void TestGetDecimal() {
DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance();
if (!dtpg.getDecimal().equals(".")) {
errln("DateTimePatternGenerator.getDecimal() was to return '.' " + "when the object gets a new instance.");
}
String[] cases = { ",", "-", "", "*", "&", "a", "0" };
for (int i = 0; i < cases.length; i++) {
dtpg.setDecimal(cases[i]);
if (!dtpg.getDecimal().equals(cases[i])) {
errln("DateTimePatternGenerator.getDecimal() was to return " + cases[i] + "when setting decimal with " + cases[i]);
}
}
}
use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestOptions.
@Test
public void TestOptions() {
final TestOptionsItem[] testOptionsData = { new TestOptionsItem("en", "Hmm", "HH:mm", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en", "HHmm", "HH:mm", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en", "hhmm", "h:mm a", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en", "Hmm", "HH:mm", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH), new TestOptionsItem("en", "HHmm", "HH:mm", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH), new TestOptionsItem("en", "hhmm", "hh:mm a", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH), new TestOptionsItem("da", "Hmm", "HH.mm", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("da", "HHmm", "HH.mm", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("da", "hhmm", "h.mm a", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("da", "Hmm", "H.mm", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH), new TestOptionsItem("da", "HHmm", "HH.mm", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH), new TestOptionsItem("da", "hhmm", "hh.mm a", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH), //
new TestOptionsItem("en", "yyyy", "yyyy", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en", "YYYY", "YYYY", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en", "U", "y", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=japanese", "yyyy", "y G", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=japanese", "YYYY", "Y G", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=japanese", "U", "y G", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "yyyy", "r(U)", DateTimePatternGenerator.MATCH_NO_OPTIONS), // not a good result, want r(Y) or r(U)
new TestOptionsItem("en@calendar=chinese", "YYYY", "Y(Y)", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "U", "r(U)", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "Gy", "r(U)", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "GU", "r(U)", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "ULLL", "MMM U", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "yMMM", "MMM r(U)", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("en@calendar=chinese", "GUMMM", "MMM r(U)", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "yyyy", "rU\u5E74", DateTimePatternGenerator.MATCH_NO_OPTIONS), // not a good result, want r(Y) or r(U)
new TestOptionsItem("zh@calendar=chinese", "YYYY", "YY\u5E74", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "U", "rU\u5E74", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "Gy", "rU\u5E74", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "GU", "rU\u5E74", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "ULLL", "U\u5E74MMM", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "yMMM", "rU\u5E74MMM", DateTimePatternGenerator.MATCH_NO_OPTIONS), new TestOptionsItem("zh@calendar=chinese", "GUMMM", "rU\u5E74MMM", DateTimePatternGenerator.MATCH_NO_OPTIONS) };
for (int i = 0; i < testOptionsData.length; ++i) {
ULocale uloc = new ULocale(testOptionsData[i].locale);
DateTimePatternGenerator dtpgen = DateTimePatternGenerator.getInstance(uloc);
String pattern = dtpgen.getBestPattern(testOptionsData[i].skeleton, testOptionsData[i].options);
if (pattern.compareTo(testOptionsData[i].expectedPattern) != 0) {
errln("Locale " + testOptionsData[i].locale + ", skeleton " + testOptionsData[i].skeleton + ", options " + ((testOptionsData[i].options != 0) ? "!=0" : "==0") + ", expected pattern " + testOptionsData[i].expectedPattern + ", got " + pattern);
}
}
}
use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestFreezeAndCloneAsThawed.
/* Tests the method
* public Object freeze()
* public Object cloneAsThawed()
*/
@Test
public void TestFreezeAndCloneAsThawed() {
DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance();
if (dtpg.isFrozen() != false) {
errln("DateTimePatternGenerator.isFrozen() is suppose to return false " + "for a DateTimePatternGenerator object that was just " + "created.");
}
dtpg.freeze();
if (dtpg.isFrozen() != true) {
errln("DateTimePatternGenerator.isFrozen() is suppose to return true " + "for a DateTimePatternGenerator object that was just " + "created and freeze.");
}
DateTimePatternGenerator dtpg2 = dtpg.cloneAsThawed();
if (dtpg.isFrozen() != false) {
errln("DateTimePatternGenerator.isFrozen() is suppose to return false " + "for a DateTimePatternGenerator object that was just " + "clone as thawed.");
}
if (dtpg2.isFrozen() != false) {
errln("DateTimePatternGenerator.isFrozen() is suppose to return false " + "for a second DateTimePatternGenerator object that was just " + "clone as thawed.");
}
}
Aggregations