void CalendarLimitTest::TestLimitsThread(int32_t threadNum) { logln("thread %d starting", threadNum); int32_t testIndex = 0; LocalPointer<Calendar> cal; while (gTestCaseIterator.next(testIndex)) { TestCase &testCase = TestCases[testIndex]; logln("begin test of %s calendar.", testCase.type); UErrorCode status = U_ZERO_ERROR; char buf[64]; uprv_strcpy(buf, "root@calendar="); strcat(buf, testCase.type); cal.adoptInstead(Calendar::createInstance(buf, status)); if (failure(status, "Calendar::createInstance", TRUE)) { continue; } if (uprv_strcmp(cal->getType(), testCase.type) != 0) { errln((UnicodeString)"FAIL: Wrong calendar type: " + cal->getType() + " Requested: " + testCase.type); continue; } doTheoreticalLimitsTest(*(cal.getAlias()), testCase.hasLeapMonth); doLimitsTest(*(cal.getAlias()), testCase.actualTestStart, testCase.actualTestEnd); logln("end test of %s calendar.", testCase.type); } }
void CalendarLimitTest::TestLimits(void) { static const UDate DEFAULT_START = 944006400000.0; // 1999-12-01T00:00Z static const int32_t DEFAULT_END = -120; // Default for non-quick is run 2 minutes static const struct { const char *type; UBool hasLeapMonth; UDate actualTestStart; int32_t actualTestEnd; } TestCases[] = { {"gregorian", FALSE, DEFAULT_START, DEFAULT_END}, {"japanese", FALSE, 596937600000.0, DEFAULT_END}, // 1988-12-01T00:00Z, Showa 63 {"buddhist", FALSE, DEFAULT_START, DEFAULT_END}, {"roc", FALSE, DEFAULT_START, DEFAULT_END}, {"persian", FALSE, DEFAULT_START, DEFAULT_END}, {"islamic-civil", FALSE, DEFAULT_START, DEFAULT_END}, {"islamic", FALSE, DEFAULT_START, 800000}, // Approx. 2250 years from now, after which some rounding errors occur in Islamic calendar {"hebrew", TRUE, DEFAULT_START, DEFAULT_END}, {"chinese", TRUE, DEFAULT_START, DEFAULT_END}, {"dangi", TRUE, DEFAULT_START, DEFAULT_END}, {"indian", FALSE, DEFAULT_START, DEFAULT_END}, {"coptic", FALSE, DEFAULT_START, DEFAULT_END}, {"ethiopic", FALSE, DEFAULT_START, DEFAULT_END}, {"ethiopic-amete-alem", FALSE, DEFAULT_START, DEFAULT_END}, {NULL, FALSE, 0, 0} }; int16_t i = 0; char buf[64]; for (i = 0; TestCases[i].type; i++) { UErrorCode status = U_ZERO_ERROR; uprv_strcpy(buf, "root@calendar="); strcat(buf, TestCases[i].type); Calendar *cal = Calendar::createInstance(buf, status); if (failure(status, "Calendar::createInstance", TRUE)) { continue; } if (uprv_strcmp(cal->getType(), TestCases[i].type) != 0) { errln((UnicodeString)"FAIL: Wrong calendar type: " + cal->getType() + " Requested: " + TestCases[i].type); delete cal; continue; } // Do the test doTheoreticalLimitsTest(*cal, TestCases[i].hasLeapMonth); doLimitsTest(*cal, TestCases[i].actualTestStart,TestCases[i].actualTestEnd); delete cal; } }
void CalendarLimitTest::TestLimits(void) { static const UDate DEFAULT_START = 944006400000.0; // 1999-12-01T00:00Z static const struct { const char *type; UBool hasLeapMonth; UDate actualTestStart; } TestCases[] = { {"gregorian", FALSE, DEFAULT_START}, {"japanese", FALSE, 596937600000.0}, // 1988-12-01T00:00Z, Showa 63 {"buddhist", FALSE, DEFAULT_START}, {"roc", FALSE, DEFAULT_START}, {"persian", FALSE, DEFAULT_START}, {"islamic-civil", FALSE, DEFAULT_START}, //{"islamic", FALSE, DEFAULT_START}, // TODO: there is a bug in monthlength calculation {"hebrew", TRUE, DEFAULT_START}, {"chinese", TRUE, DEFAULT_START}, {"indian", FALSE, DEFAULT_START}, {"coptic", FALSE, DEFAULT_START}, {"ethiopic", FALSE, DEFAULT_START}, {"ethiopic-amete-alem", FALSE, DEFAULT_START}, {NULL, FALSE, 0.0} }; int16_t i = 0; char buf[64]; for (i = 0; TestCases[i].type; i++) { UErrorCode status = U_ZERO_ERROR; uprv_strcpy(buf, "root@calendar="); strcat(buf, TestCases[i].type); Calendar *cal = Calendar::createInstance(buf, status); if (failure(status, "Calendar::createInstance")) { continue; } if (uprv_strcmp(cal->getType(), TestCases[i].type) != 0) { errln((UnicodeString)"FAIL: Wrong calendar type: " + cal->getType() + " Requested: " + TestCases[i].type); delete cal; continue; } // Do the test doTheoreticalLimitsTest(*cal, TestCases[i].hasLeapMonth); doLimitsTest(*cal, TestCases[i].actualTestStart); delete cal; } }