text
stringlengths
0
2.2M
//: 3 Test that 'loadTimeZone' returns a non-zero return code other
//: than 'k_UNSUPPORTED_ID' if 'rootPath' is not plausible.
//
// Testing:
// int loadTimeZone(Zoneinfo *result, const char *timeZoneId);
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "TESTING 'loadTimeZone'" << endl
<< "======================" << endl;
if (verbose) cout << "\nSetup plausible directory" << endl;
ASSERT(true == Obj::isPlausibleZoneinfoRootPath(TEST_DIRECTORY));
if (verbose) cout << "\nTest non-plausible directory" << endl;
{
Obj mX;
baltzo::Zoneinfo timeZone;
mX.configureRootPath("NotPlausibleDirectory");
int rc = mX.loadTimeZone(&timeZone, "A");
ASSERT(0 != rc);
ASSERT(baltzo::ErrorCode::k_UNSUPPORTED_ID != rc);
}
if (verbose) cout << "\nTest with plausible directory" << endl;
{
Obj mX;
baltzo::Zoneinfo timeZone;
ASSERT(0 == mX.configureRootPathIfPlausible(TEST_DIRECTORY));
if (verbose) cout << "\n\tTest invalid identifier" << endl;
ASSERT(baltzo::ErrorCode::k_UNSUPPORTED_ID ==
mX.loadTimeZone(&timeZone, "/"));
if (verbose) cout << "\n\tTest non-existent identifier" << endl;
ASSERT(baltzo::ErrorCode::k_UNSUPPORTED_ID ==
mX.loadTimeZone(&timeZone, "Non/Existent/Identifier"));
ASSERT(0 == mX.loadTimeZone(&timeZone, AMERICA_NEW_YORK_ID));
ASSERT(AMERICA_NEW_YORK_ID == timeZone.identifier());
}
#ifndef BDE_OMIT_INTERNAL_DEPRECATED
ASSERT(baltzo::ErrorCode::k_UNSUPPORTED_ID ==
baltzo::ErrorCode::k_UNSUPPORTED_ID);
#endif // BDE_OMIT_INTERNAL_DEPRECATED
} break;
case 5: {
// --------------------------------------------------------------------
// TESTING 'loadTimeZoneFilePath'
//
// Concerns:
//: 1 All invalid characters cause 'loadTimeZoneFilePath' to return a
//: non-zero value.
//:
//: 2 'loadTimeZoneFilePath' accepts all valid characters in the
//: 'timeZoneId'.
//:
//: 3 'loadTimeZoneFilePath' returns the expected result as specified
//: in the contract.
//:
//: 4 'loadTimeZoneFilePath' accepts all current time zone identifiers.
//
// Plan:
//: 1 Create a list of invalid character and test that
//: 'loadTimeZoneFilePath' returns a non-zero value for each one of
//: them.
//:
//: 2 Test that 'loadTimeZoneFilePath' succeed when given a time zone
//: identifier that contains only valid character.
//:
//: 3 Test that 'loadTimeZoneFilePath' produce expected results at the
//: documented boundaries.
//:
//: 4 Create a list of sample time zone identifiers and test that the
//: the correct file path is returned.
//
// Testing:
// int loadTimeZoneFilePath(bsl::string *r, const char *id) const;
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "TESTING 'loadTimeZoneFilePath'" << endl
<< "==============================" << endl;
if (verbose) cout << "\nTesting invalid characters." << endl;
{
const char *INVALID_CHAR = "`~!@#$%^&*()=,./;'[]\\<>?:\"{}|";
const bsl::size_t NUM_INVALID_CHAR = strlen(INVALID_CHAR);
Obj mX; const Obj& X = mX;
mX.configureRootPath(".");