use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestCheckFrozen.
/* Tests the method
* private void checkFrozen()
* from public void setDateTimeFormat(String dateTimeFormat)
*/
@Test
public void TestCheckFrozen() {
// Tests when "if (isFrozen())" is true
DateTimePatternGenerator dt = DateTimePatternGenerator.getInstance();
try {
dt.freeze();
dt.setDateTimeFormat("MMDDYYYY");
errln("DateTimePatternGenerator.checkFrozen() was suppose to " + "return an exception when trying to setDateTimeFormat " + "for a frozen object.");
} catch (Exception e) {
}
dt = dt.cloneAsThawed();
}
use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestGetBaseSkeleton.
/* Tests the method
* public String getBaseSkeleton(String pattern)
*/
@Test
public void TestGetBaseSkeleton() {
DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance();
String[] cases = { "MMDD", "MMMDD", "MMM-DD", "DD/MMM", "ddM", "MMMMd" };
String[] results = { "MD", "MMMD", "MMMD", "MMMD", "Md", "MMMMd" };
for (int i = 0; i < cases.length; i++) {
if (!dtpg.getBaseSkeleton(cases[i]).equals(results[i])) {
errln("DateTimePatternGenerator.getSkeleton(String) did " + "return the expected result when passing " + cases[i] + " and expected " + results[i] + " but got " + dtpg.getBaseSkeleton(cases[i]));
}
}
}
use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestGetRedundants.
/* Tests the method
* public Collection<String> getRedundants(Collection<String> output)
*/
@Test
public void TestGetRedundants() {
DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance();
// Tests when "if (output == null)" is true
try {
dtpg.getRedundants(null);
} catch (Exception e) {
errln("DateTimeGenerator.getRedundants was not supposed to return " + "an exception when passing a null parameter: " + e);
}
// Tests when "if (output == null)" is false
try {
Collection<String> out = new LinkedHashSet<String>();
dtpg.getRedundants(out);
} catch (Exception e) {
errln("DateTimeGenerator.getRedundants was not supposed to return " + "an exception when passing a new LinkedHashSet<String>() parameter: " + e);
}
}
use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestClone.
/* Tests the method
* public Object clone()
*/
@Test
public void TestClone() {
DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance();
DateTimePatternGenerator dtpg2 = (DateTimePatternGenerator) dtpg.clone();
dtpg = (DateTimePatternGenerator) dtpg2.clone();
}
use of android.icu.text.DateTimePatternGenerator in project j2objc by google.
the class DateTimeGeneratorTest method TestGetCanonicalSkeletonAllowingDuplicates.
/* Tests the method
* public String getCanonicalSkeletonAllowingDuplicates(String pattern)
*/
public void TestGetCanonicalSkeletonAllowingDuplicates() {
DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance();
String[] cases = { "GyQMwEdaHmsSv", "LegH", "Legh" };
String[] results = { "GyQMwEdHmsSv", "MEdH", "MEdh" };
for (int i = 0; i < cases.length; i++) {
if (!dtpg.getCanonicalSkeletonAllowingDuplicates(cases[i]).equals(results[i])) {
errln("DateTimePatternGenerator.getCanonicalSkeletonAllowingDuplicates(String) did " + "return the expected result when passing " + cases[i] + " and expected " + results[i] + " but got " + dtpg.getCanonicalSkeletonAllowingDuplicates(cases[i]));
}
}
}
Aggregations