Skip to content

Commit 3b92de3

Browse files
committed
ICU-23274 Fix 1987 Leap Month 6 vs 7 boundary bug and add Y.T. Liu verification suite across 5,301 years in chinesecalendar.txt
- Add 1,040 data-driven verification test cases in chinesecalendar.txt (covering 1645-1901 CE, 2101-2500 CE, and 10% sampled mismatches in 3000 BCE-1644 CE) using EXTENDED_YEAR notation. - Implement kNewMoonCorrections / NEW_MOON_CORRECTIONS binary search table and bidirectional boundary check in newMoonNear in C++ (chnsecal.cpp) and Java (ChineseCalendar.java). - Add HKO PDF reference comments and notes for 2057/2097. - Verify 100% test pass in C++ and Java exhaustive test suites.
1 parent d38a2e6 commit 3b92de3

10 files changed

Lines changed: 21310 additions & 7 deletions

File tree

icu4c/source/i18n/chnsecal.cpp

Lines changed: 1107 additions & 1 deletion
Large diffs are not rendered by default.

icu4c/source/test/intltest/dadrcal.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ DataDrivenCalendarTest::~DataDrivenCalendarTest() {
3838
delete driver;
3939
}
4040

41+
DataDrivenCalendarTest::DataDrivenCalendarTest(const char* bundleName) {
42+
UErrorCode status = U_ZERO_ERROR;
43+
driver = TestDataModule::getTestDataModule(bundleName, *this, status);
44+
}
45+
46+
DataDrivenChineseCalendarTest::DataDrivenChineseCalendarTest() : DataDrivenCalendarTest("chinesecalendar") {
47+
}
48+
49+
DataDrivenChineseCalendarTest::~DataDrivenChineseCalendarTest() {
50+
}
51+
4152
void DataDrivenCalendarTest::runIndexedTest(int32_t index, UBool exec,
4253
const char* &name, char* /*par */) {
4354
if (driver != nullptr) {
@@ -393,6 +404,9 @@ void DataDrivenCalendarTest::testConvert(TestData *testData,
393404
int n = 0;
394405
while (testData->nextCase(currentCase, status)) {
395406
++n;
407+
if (quick && strcmp(testData->getName(), "TestChineseCalendar") == 0 && (n % 33) != 1) {
408+
continue;
409+
}
396410
LocalPointer<Calendar> fromCalendar;
397411
UnicodeString locale = currentCase->getString("locale", status);
398412
if (U_SUCCESS(status)) {

icu4c/source/test/intltest/dadrcal.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ class DataDrivenCalendarTest : public IntlTest {
4545
void testConvert(int32_t n, const CalendarFieldsSet &fromSet,
4646
Calendar *fromCal, const CalendarFieldsSet &toSet, Calendar *toCal,
4747
UBool fwd);
48-
private:
48+
protected:
49+
DataDrivenCalendarTest(const char* bundleName);
4950
TestDataModule *driver;
5051
};
5152

53+
class DataDrivenChineseCalendarTest : public DataDrivenCalendarTest {
54+
public:
55+
DataDrivenChineseCalendarTest();
56+
virtual ~DataDrivenChineseCalendarTest();
57+
};
58+
5259
#endif /* #if !UCONFIG_NO_COLLATION */
5360

5461
#endif

icu4c/source/test/intltest/itformat.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &nam
292292
#if !UCONFIG_NO_MF2
293293
TESTCLASS(60,TestMessageFormat2);
294294
#endif
295+
#endif
296+
#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
297+
TESTCLASS(61,DataDrivenChineseCalendarTest);
295298
#endif
296299
default: name = ""; break; //needed to end loop
297300
}

icu4c/source/test/testdata/BUILDRULES.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def generate(config, io, common_vars):
2828
def generate_rb(config, io, common_vars):
2929
basenames = [
3030
"calendar",
31+
"chinesecalendar",
3132
"casing",
3233
"conversion",
3334
"format",

0 commit comments

Comments
 (0)