EventRecurrenceTestpublic class EventRecurrenceTest extends TestCase
Methods Summary |
---|
private static void | cmp(int vlen, int[] v, int[] correct, java.lang.String name)
if ((correct == null && v != null)
|| (correct != null && v == null)) {
throw new RuntimeException("One is null, one isn't for " + name
+ ": correct=" + Arrays.toString(correct)
+ " actual=" + Arrays.toString(v));
}
if ((correct == null && vlen != 0)
|| (vlen != (correct == null ? 0 : correct.length))) {
throw new RuntimeException("Reported length mismatch for " + name
+ ": correct=" + ((correct == null) ? "null" : correct.length)
+ " actual=" + vlen);
}
if (correct == null) {
return;
}
if (v.length < correct.length) {
throw new RuntimeException("Array length mismatch for " + name
+ ": correct=" + Arrays.toString(correct)
+ " actual=" + Arrays.toString(v));
}
for (int i = 0; i < correct.length; i++) {
if (v[i] != correct[i]) {
throw new RuntimeException("Array value mismatch for " + name
+ ": correct=" + Arrays.toString(correct)
+ " actual=" + Arrays.toString(v));
}
}
| private static boolean | eq(java.lang.String a, java.lang.String b)
if ((a == null && b != null) || (a != null && b == null)) {
return false;
} else {
return a == b || a.equals(b);
}
| public void | fakeTestXX()
verifyRecurType("FREQ=DAILY;",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| private static void | print(android.pim.EventRecurrence er)
System.out.println("{");
System.out.println(" freq=" + er.freq);
System.out.println(" until=" + er.until);
System.out.println(" count=" + er.count);
System.out.println(" interval=" + er.interval);
System.out.println(" wkst=" + er.wkst);
System.out.println(" bysecond=" + Arrays.toString(er.bysecond));
System.out.println(" bysecondCount=" + er.bysecondCount);
System.out.println(" byminute=" + Arrays.toString(er.byminute));
System.out.println(" byminuteCount=" + er.byminuteCount);
System.out.println(" byhour=" + Arrays.toString(er.byhour));
System.out.println(" byhourCount=" + er.byhourCount);
System.out.println(" byday=" + Arrays.toString(er.byday));
System.out.println(" bydayNum=" + Arrays.toString(er.bydayNum));
System.out.println(" bydayCount=" + er.bydayCount);
System.out.println(" bymonthday=" + Arrays.toString(er.bymonthday));
System.out.println(" bymonthdayCount=" + er.bymonthdayCount);
System.out.println(" byyearday=" + Arrays.toString(er.byyearday));
System.out.println(" byyeardayCount=" + er.byyeardayCount);
System.out.println(" byweekno=" + Arrays.toString(er.byweekno));
System.out.println(" byweeknoCount=" + er.byweeknoCount);
System.out.println(" bymonth=" + Arrays.toString(er.bymonth));
System.out.println(" bymonthCount=" + er.bymonthCount);
System.out.println(" bysetpos=" + Arrays.toString(er.bysetpos));
System.out.println(" bysetposCount=" + er.bysetposCount);
System.out.println("}");
| public void | test0()
verifyRecurType("FREQ=SECONDLY",
/* int freq */ EventRecurrence.SECONDLY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test1()
verifyRecurType("FREQ=MINUTELY",
/* int freq */ EventRecurrence.MINUTELY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test10()
// verifyRecurType all of the BY* ones with one element
verifyRecurType("FREQ=DAILY"
+ ";BYSECOND=0"
+ ";BYMINUTE=1"
+ ";BYHOUR=2"
+ ";BYMONTHDAY=30"
+ ";BYYEARDAY=300"
+ ";BYWEEKNO=53"
+ ";BYMONTH=12"
+ ";BYSETPOS=-15"
+ ";WKST=SU",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ new int[]{0},
/* int[] byminute */ new int[]{1},
/* int[] byhour */ new int[]{2},
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ new int[]{30},
/* int[] byyearday */ new int[]{300},
/* int[] byweekno */ new int[]{53},
/* int[] bymonth */ new int[]{12},
/* int[] bysetpos */ new int[]{-15},
/* int wkst */ EventRecurrence.SU
);
| public void | test11()
// verifyRecurType all of the BY* ones with one element
verifyRecurType("FREQ=DAILY"
+ ";BYSECOND=0,30,59"
+ ";BYMINUTE=0,41,59"
+ ";BYHOUR=0,4,23"
+ ";BYMONTHDAY=-31,-1,1,31"
+ ";BYYEARDAY=-366,-1,1,366"
+ ";BYWEEKNO=-53,-1,1,53"
+ ";BYMONTH=1,12"
+ ";BYSETPOS=1,2,3,4,500,10000"
+ ";WKST=SU",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ new int[]{0, 30, 59},
/* int[] byminute */ new int[]{0, 41, 59},
/* int[] byhour */ new int[]{0, 4, 23},
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ new int[]{-31, -1, 1, 31},
/* int[] byyearday */ new int[]{-366, -1, 1, 366},
/* int[] byweekno */ new int[]{-53, -1, 1, 53},
/* int[] bymonth */ new int[]{1, 12},
/* int[] bysetpos */ new int[]{1, 2, 3, 4, 500, 10000},
/* int wkst */ EventRecurrence.SU
);
| public void | test12()
Check[] checks = new Check[]{
new Check("BYSECOND", -100, -1, 60, 100),
new Check("BYMINUTE", -100, -1, 60, 100),
new Check("BYHOUR", -100, -1, 24, 100),
new Check("BYMONTHDAY", -100, -32, 0, 32, 100),
new Check("BYYEARDAY", -400, -367, 0, 367, 400),
new Check("BYWEEKNO", -100, -54, 0, 54, 100),
new Check("BYMONTH", -100, -5, 0, 13, 100)
};
for (Check ck : checks) {
for (int n : ck.values) {
String recur = "FREQ=DAILY;" + ck.key + "=" + n;
try {
EventRecurrence er = new EventRecurrence();
er.parse(recur);
fail("Negative verifyRecurType failed. "
+ " parse failed to throw an exception for '"
+ recur + "'");
} catch (EventRecurrence.InvalidFormatException e) {
// expected
}
}
}
| public void | test13()
verifyRecurType("FREQ=DAILY;BYDAY=1SU,-2MO,+33TU,WE,TH,FR,SA",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ new int[]{
EventRecurrence.SU,
EventRecurrence.MO,
EventRecurrence.TU,
EventRecurrence.WE,
EventRecurrence.TH,
EventRecurrence.FR,
EventRecurrence.SA
},
/* int[] bydayNum */ new int[]{1, -2, 33, 0, 0, 0, 0},
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test2()
verifyRecurType("FREQ=HOURLY",
/* int freq */ EventRecurrence.HOURLY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test3()
verifyRecurType("FREQ=DAILY",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test4()
verifyRecurType("FREQ=WEEKLY",
/* int freq */ EventRecurrence.WEEKLY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test5()
verifyRecurType("FREQ=MONTHLY",
/* int freq */ EventRecurrence.MONTHLY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test6()
verifyRecurType("FREQ=YEARLY",
/* int freq */ EventRecurrence.YEARLY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test7()
// with an until
verifyRecurType("FREQ=DAILY;UNTIL=112233T223344Z",
/* int freq */ EventRecurrence.DAILY,
/* String until */ "112233T223344Z",
/* int count */ 0,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test8()
// with a count
verifyRecurType("FREQ=DAILY;COUNT=334",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 334,
/* int interval */ 0,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| public void | test9()
// with a count
verifyRecurType("FREQ=DAILY;INTERVAL=5000",
/* int freq */ EventRecurrence.DAILY,
/* String until */ null,
/* int count */ 0,
/* int interval */ 5000,
/* int[] bysecond */ null,
/* int[] byminute */ null,
/* int[] byhour */ null,
/* int[] byday */ null,
/* int[] bydayNum */ null,
/* int[] bymonthday */ null,
/* int[] byyearday */ null,
/* int[] byweekno */ null,
/* int[] bymonth */ null,
/* int[] bysetpos */ null,
/* int wkst */ EventRecurrence.MO
);
| private static void | verifyRecurType(java.lang.String recur, int freq, java.lang.String until, int count, int interval, int[] bysecond, int[] byminute, int[] byhour, int[] byday, int[] bydayNum, int[] bymonthday, int[] byyearday, int[] byweekno, int[] bymonth, int[] bysetpos, int wkst)
EventRecurrence eventRecurrence = new EventRecurrence();
eventRecurrence.parse(recur);
if (eventRecurrence.freq != freq
|| !eq(eventRecurrence.until, until)
|| eventRecurrence.count != count
|| eventRecurrence.interval != interval
|| eventRecurrence.wkst != wkst) {
System.out.println("Error... got:");
print(eventRecurrence);
System.out.println("expected:");
System.out.println("{");
System.out.println(" freq=" + freq);
System.out.println(" until=" + until);
System.out.println(" count=" + count);
System.out.println(" interval=" + interval);
System.out.println(" wkst=" + wkst);
System.out.println(" bysecond=" + Arrays.toString(bysecond));
System.out.println(" byminute=" + Arrays.toString(byminute));
System.out.println(" byhour=" + Arrays.toString(byhour));
System.out.println(" byday=" + Arrays.toString(byday));
System.out.println(" bydayNum=" + Arrays.toString(bydayNum));
System.out.println(" bymonthday=" + Arrays.toString(bymonthday));
System.out.println(" byyearday=" + Arrays.toString(byyearday));
System.out.println(" byweekno=" + Arrays.toString(byweekno));
System.out.println(" bymonth=" + Arrays.toString(bymonth));
System.out.println(" bysetpos=" + Arrays.toString(bysetpos));
System.out.println("}");
throw new RuntimeException("Mismatch in fields");
}
cmp(eventRecurrence.bysecondCount, eventRecurrence.bysecond, bysecond, "bysecond");
cmp(eventRecurrence.byminuteCount, eventRecurrence.byminute, byminute, "byminute");
cmp(eventRecurrence.byhourCount, eventRecurrence.byhour, byhour, "byhour");
cmp(eventRecurrence.bydayCount, eventRecurrence.byday, byday, "byday");
cmp(eventRecurrence.bydayCount, eventRecurrence.bydayNum, bydayNum, "bydayNum");
cmp(eventRecurrence.bymonthdayCount, eventRecurrence.bymonthday, bymonthday, "bymonthday");
cmp(eventRecurrence.byyeardayCount, eventRecurrence.byyearday, byyearday, "byyearday");
cmp(eventRecurrence.byweeknoCount, eventRecurrence.byweekno, byweekno, "byweekno");
cmp(eventRecurrence.bymonthCount, eventRecurrence.bymonth, bymonth, "bymonth");
cmp(eventRecurrence.bysetposCount, eventRecurrence.bysetpos, bysetpos, "bysetpos");
|
|