MojErr MojDbDistinctTest::run() { // TODO : description, youngseung.ji MojDb db; MojErr err = db.open(MojDbTestDir); MojTestErrCheck(err); // add kind MojObject kindObj; err = kindObj.fromJson(MojDistinctKindStr); MojTestErrCheck(err); err = db.putKind(kindObj); MojTestErrCheck(err); // put test objects for (MojSize i = 0; i < sizeof(MojDistinctTestObjects) / sizeof(MojChar*); ++i) { MojObject obj; err = obj.fromJson(MojDistinctTestObjects[i]); MojTestErrCheck(err); err = db.put(obj); MojTestErrCheck(err); } // Start testing err = simpleTest(db); MojTestErrCheck(err); err = db.close(); MojTestErrCheck(err); return MojErrNone; }
MojErr MojDbIndexTest::run() { MojErr err = invalidTest(); MojTestErrCheck(err); err = simpleTest(); MojTestErrCheck(err); err = nestedTest(); MojTestErrCheck(err); err = compoundTest(); MojTestErrCheck(err); err = canAnswerTest(); MojTestErrCheck(err); err = deletedTest(); MojTestErrCheck(err); err = wildcardTest(); MojTestErrCheck(err); err = defaultValuesTest(); MojTestErrCheck(err); err = multiTest(); MojTestErrCheck(err); err = tokenizeTest(); MojTestErrCheck(err); return MojErrNone; }
int main(int argc, char * argv[]) { simpleTest(); joinLeaveDestroyTest(); pluralTest(); boundsTest(); return 0; }
int main() { if (!simpleTest()) exit(EXIT_FAILURE); if (!StreamConsumerTester::test()) exit(EXIT_FAILURE); exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { simpleTest(); easierTest(); harderTest(); fprintf(stderr, "All tests OK!\n"); exit(0); }
MojErr MojDbSearchTest::run() { MojDb db; MojErr err = db.open(MojDbTestDir); MojTestErrCheck(err); // add kind MojObject kindObj; err = kindObj.fromJson(MojSearchKindStr); MojTestErrCheck(err); err = db.putKind(kindObj); MojTestErrCheck(err); // put test objects for (MojSize i = 0; i < sizeof(MojSearchTestObjects) / sizeof(MojChar*); ++i) { MojObject obj; err = obj.fromJson(MojSearchTestObjects[i]); MojTestErrCheck(err); err = db.put(obj); MojTestErrCheck(err); } err = simpleTest(db); MojTestErrCheck(err); err = filterTest(db); MojTestErrCheck(err); // add kind for page test err = kindObj.fromJson(MojSearchKindStr2); MojTestErrCheck(err); err = db.putKind(kindObj); MojTestErrCheck(err); // put test objects for page test for (MojSize i = 0; i < sizeof(MojSearchTestObjects2) / sizeof(MojChar*); ++i) { MojObject obj; err = obj.fromJson(MojSearchTestObjects2[i]); MojTestErrCheck(err); err = db.put(obj); MojTestErrCheck(err); } err = pageTest(db); MojTestErrCheck(err); err = db.close(); MojTestErrCheck(err); return MojErrNone; }
void IntlCalendarTest::TestJapaneseFormat() { Calendar *cal; UErrorCode status = U_ZERO_ERROR; cal = Calendar::createInstance("ja_JP_TRADITIONAL", status); CHECK(status, UnicodeString("Creating ja_JP_TRADITIONAL calendar")); Calendar *cal2 = cal->clone(); delete cal; cal = NULL; // Test simple parse/format with adopt UDate aDate = 999932400000.0; SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yy G"), Locale("en_US@calendar=japanese"), status); SimpleDateFormat *fmt2 = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US@calendar=gregorian"), status); CHECK(status, "creating date format instance"); if(!fmt) { errln("Coudln't create en_US instance"); } else { UnicodeString str; fmt2->format(aDate, str); logln(UnicodeString() + "Test Date: " + str); str.remove(); fmt->format(aDate, str); logln(UnicodeString() + "as Japanese Calendar: " + str); UnicodeString expected("September 8, 13 Heisei"); if(str != expected) { errln("Expected " + expected + " but got " + str); } UDate otherDate = fmt->parse(expected, status); if(otherDate != aDate) { UnicodeString str3; ParsePosition pp; fmt->parse(expected, *cal2, pp); fmt->format(otherDate, str3); errln("Parse incorrect of " + expected + " - wanted " + aDate + " but got " + " = " + otherDate + ", " + str3 + " = " + CalendarTest::calToStr(*cal2) ); } else { logln("Parsed OK: " + expected); } delete fmt; } // Test parse with incomplete information fmt = new SimpleDateFormat(UnicodeString("G y"), Locale("en_US@calendar=japanese"), status); aDate = -3197117222000.0; CHECK(status, "creating date format instance"); if(!fmt) { errln("Coudln't create en_US instance"); } else { UnicodeString str; fmt2->format(aDate, str); logln(UnicodeString() + "Test Date: " + str); str.remove(); fmt->format(aDate, str); logln(UnicodeString() + "as Japanese Calendar: " + str); UnicodeString expected("Meiji 1"); if(str != expected) { errln("Expected " + expected + " but got " + str); } UDate otherDate = fmt->parse(expected, status); if(otherDate != aDate) { UnicodeString str3; ParsePosition pp; fmt->parse(expected, *cal2, pp); fmt->format(otherDate, str3); errln("Parse incorrect of " + expected + " - wanted " + aDate + " but got " + " = " + otherDate + ", " + str3 + " = " + CalendarTest::calToStr(*cal2) ); } else { logln("Parsed OK: " + expected); } delete fmt; } delete cal2; delete fmt2; CHECK(status, "Error occured"); // Now, try in Japanese { UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5"); UDate expectDate = 999932400000.0; // Testing a recent date Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5"); UDate expectDate = 999932400000.0; // Testing a recent date Locale loc("ja_JP_TRADITIONAL"); // legacy status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { UnicodeString expect = CharsToUnicodeString("\\u5b89\\u6c385\\u5e747\\u67084\\u65e5\\u6728\\u66dc\\u65e5"); UDate expectDate = -6106032422000.0; // 1776-07-04T00:00:00Z-075258 Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { // Jitterbug 1869 - this is an ambiguous era. (Showa 64 = Jan 6 1989, but Showa could be 2 other eras) ) UnicodeString expect = CharsToUnicodeString("\\u662d\\u548c64\\u5e741\\u67086\\u65e5\\u91d1\\u66dc\\u65e5"); UDate expectDate = 600076800000.0; Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { // This Feb 29th falls on a leap year by gregorian year, but not by Japanese year. UnicodeString expect = CharsToUnicodeString("\\u5EB7\\u6B632\\u5e742\\u670829\\u65e5\\u65e5\\u66dc\\u65e5"); UDate expectDate = -16214400422000.0; // 1456-03-09T00:00Z-075258 Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } }
void IntlCalendarTest::TestBuddhistFormat() { UErrorCode status = U_ZERO_ERROR; // Test simple parse/format with adopt // First, a contrived english test.. UDate aDate = 999932400000.0; SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US@calendar=buddhist"), status); CHECK(status, "creating date format instance"); SimpleDateFormat *fmt2 = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US@calendar=gregorian"), status); CHECK(status, "creating gregorian date format instance"); if(!fmt) { errln("Coudln't create en_US instance"); } else { UnicodeString str; fmt2->format(aDate, str); logln(UnicodeString() + "Test Date: " + str); str.remove(); fmt->format(aDate, str); logln(UnicodeString() + "as Buddhist Calendar: " + escape(str)); UnicodeString expected("September 8, 2544 BE"); if(str != expected) { errln("Expected " + escape(expected) + " but got " + escape(str)); } UDate otherDate = fmt->parse(expected, status); if(otherDate != aDate) { UnicodeString str3; fmt->format(otherDate, str3); errln("Parse incorrect of " + escape(expected) + " - wanted " + aDate + " but got " + otherDate + ", " + escape(str3)); } else { logln("Parsed OK: " + expected); } delete fmt; } delete fmt2; CHECK(status, "Error occured testing Buddhist Calendar in English "); status = U_ZERO_ERROR; // Now, try in Thai { UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48" " 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e1e.\\u0e28. 2544"); UDate expectDate = 999932400000.0; Locale loc("th_TH_TRADITIONAL"); // legacy simpleTest(loc, expect, expectDate, status); } status = U_ZERO_ERROR; { UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48" " 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e1e.\\u0e28. 2544"); UDate expectDate = 999932400000.0; Locale loc("th_TH@calendar=buddhist"); simpleTest(loc, expect, expectDate, status); } status = U_ZERO_ERROR; { UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48" " 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e04.\\u0e28. 2001"); UDate expectDate = 999932400000.0; Locale loc("th_TH@calendar=gregorian"); simpleTest(loc, expect, expectDate, status); } status = U_ZERO_ERROR; { UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48" " 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e04.\\u0e28. 2001"); UDate expectDate = 999932400000.0; Locale loc("th_TH_TRADITIONAL@calendar=gregorian"); simpleTest(loc, expect, expectDate, status); } }
void test_main( void ) { TEST_ASSERT_EQUAL(0, simpleTest()); }
int main(int argc, char *argv[]) { printf("simpleTest:\n"); simpleTest(); printf("recursiveTest:\n"); recursiveTest(); printf("multipleTest:\n"); multipleTest(); return 0; }
void IntlCalendarTest::TestJapaneseFormat() { Calendar *cal; UErrorCode status = U_ZERO_ERROR; cal = Calendar::createInstance("ja_JP_TRADITIONAL", status); CHECK(status, UnicodeString("Creating ja_JP_TRADITIONAL calendar")); Calendar *cal2 = cal->clone(); delete cal; cal = NULL; // Test simple parse/format with adopt UDate aDate = 999932400000.0; SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yy G"), Locale("en_US@calendar=japanese"), status); SimpleDateFormat *fmt2 = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US@calendar=gregorian"), status); CHECK(status, "creating date format instance"); if(!fmt) { errln("Coudln't create en_US instance"); } else { UnicodeString str; fmt2->format(aDate, str); logln(UnicodeString() + "Test Date: " + str); str.remove(); fmt->format(aDate, str); logln(UnicodeString() + "as Japanese Calendar: " + str); UnicodeString expected("September 8, 13 Heisei"); if(str != expected) { errln("Expected " + expected + " but got " + str); } UDate otherDate = fmt->parse(expected, status); if(otherDate != aDate) { UnicodeString str3; ParsePosition pp; fmt->parse(expected, *cal2, pp); fmt->format(otherDate, str3); errln("Parse incorrect of " + expected + " - wanted " + aDate + " but got " + " = " + otherDate + ", " + str3 + " = " + CalendarTest::calToStr(*cal2) ); } else { logln("Parsed OK: " + expected); } delete fmt; } // Test parse with incomplete information fmt = new SimpleDateFormat(UnicodeString("G y"), Locale("en_US@calendar=japanese"), status); /* The test data below should points to 1868-09-08T00:00:00 in America/Los_Angeles. * The time calculated by original test code uses -7:00 UTC offset, because it assumes * DST is observed (because of a timezone bug, DST is observed for early 20th century * day to infinite past time). The bug was fixed and DST is no longer used for time before * 1900 for any zones. However, ICU timezone transition data is represented by 32-bit integer * (sec) and cannot represent transitions before 1901 defined in Olson tzdata. For example, * based on Olson definition, offset -7:52:58 should be used for Nov 18, 1883 or older dates. * If ICU properly capture entire Olson zone definition, the start time of "Meiji 1" is * -3197117222000. -Yoshito */ /* TODO: When ICU support the Olson LMT offset for America/Los_Angeles, we need to update * the reference data. */ //aDate = -3197120400000.; aDate = -3197116800000.; CHECK(status, "creating date format instance"); if(!fmt) { errln("Coudln't create en_US instance"); } else { UnicodeString str; fmt2->format(aDate, str); logln(UnicodeString() + "Test Date: " + str); str.remove(); fmt->format(aDate, str); logln(UnicodeString() + "as Japanese Calendar: " + str); UnicodeString expected("Meiji 1"); if(str != expected) { errln("Expected " + expected + " but got " + str); } UDate otherDate = fmt->parse(expected, status); if(otherDate != aDate) { UnicodeString str3; ParsePosition pp; fmt->parse(expected, *cal2, pp); fmt->format(otherDate, str3); errln("Parse incorrect of " + expected + " - wanted " + aDate + " but got " + " = " + otherDate + ", " + str3 + " = " + CalendarTest::calToStr(*cal2) ); } else { logln("Parsed OK: " + expected); } delete fmt; } delete cal2; delete fmt2; CHECK(status, "Error occured"); // Now, try in Japanese { UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5"); UDate expectDate = 999932400000.0; // Testing a recent date Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5"); UDate expectDate = 999932400000.0; // Testing a recent date Locale loc("ja_JP_TRADITIONAL"); // legacy status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { UnicodeString expect = CharsToUnicodeString("\\u5b89\\u6c385\\u5e747\\u67084\\u65e5\\u6728\\u66dc\\u65e5"); //UDate expectDate = -6106035600000.0; UDate expectDate = -6106032000000.0; // 1776-07-04T00:00:00Z-0800 Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { // Jitterbug 1869 - this is an ambiguous era. (Showa 64 = Jan 6 1989, but Showa could be 2 other eras) ) UnicodeString expect = CharsToUnicodeString("\\u662d\\u548c64\\u5e741\\u67086\\u65e5\\u91d1\\u66dc\\u65e5"); UDate expectDate = 600076800000.0; Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } { // This Feb 29th falls on a leap year by gregorian year, but not by Japanese year. UnicodeString expect = CharsToUnicodeString("\\u5EB7\\u6B632\\u5e742\\u670829\\u65e5\\u65e5\\u66dc\\u65e5"); // Add -1:00 to the following for historical TZ - aliu //UDate expectDate = -16214403600000.0; // courtesy of date format round trip test UDate expectDate = -16214400000000.0; // 1456-03-09T00:00:00Z-0800 Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); } }