Fennel: SqlDateTest Class Reference (original) (raw)
Inheritance diagram for SqlDateTest:

| Public Member Functions | |
|---|---|
| SqlDateTest () | |
| virtual | ~SqlDateTest () |
| TestSuite * | releaseTestSuite () |
| void | beforeTestCase (std::string testCaseName) |
| void | afterTestCase (std::string testCaseName) |
| virtual void | testCaseSetUp () |
| Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked. | |
| virtual void | testCaseTearDown () |
| Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked. | |
| virtual void | notifyTrace (std::string source, TraceLevel level, std::string message) |
| Receives notification when a trace event occurs. | |
| virtual TraceLevel | getSourceTraceLevel (std::string source) |
| Gets the level at which a particular source should be traced. | |
| virtual void | initTraceSource (SharedTraceTarget pTraceTarget, std::string name) |
| For use when initialization has to be deferred until after construction. | |
| void | trace (TraceLevel level, std::string message) const |
| Records a trace message. | |
| bool | isTracing () const |
| **Returns:**true iff tracing is enabled for this source | |
| bool | isTracingLevel (TraceLevel level) const |
| Determines whether a particular level is being traced. | |
| TraceTarget & | getTraceTarget () const |
| **Returns:**the TraceTarget for this source | |
| SharedTraceTarget | getSharedTraceTarget () const |
| **Returns:**the SharedTraceTarget for this source | |
| std::string | getTraceSourceName () const |
| Gets the name of this source. | |
| void | setTraceSourceName (std::string const &n) |
| Sets the name of this source. | |
| TraceLevel | getMinimumTraceLevel () const |
| void | disableTracing () |
| Static Public Member Functions | |
| static void | readParams (int argc, char **argv) |
| Parses the command line. | |
| Static Public Attributes | |
| static ParamName | paramTestSuiteName |
| static ParamName | paramTraceFileName |
| static ParamName | paramDictionaryFileName |
| static ParamName | paramTraceLevel |
| static ParamName | paramStatsFileName |
| static ParamName | paramTraceStdout |
| static ParamName | paramDegreeOfParallelism |
| static ConfigMap | configMap |
| Configuration parameters. | |
| Protected Member Functions | |
| void | snooze (uint nSeconds) |
| Protected Attributes | |
| TestSuite * | pTestSuite |
| Boost test suite. | |
| boost::shared_ptr< TestBase > | pTestObj |
| std::ofstream | traceStream |
| Output file stream for tracing. | |
| StrictMutex | traceMutex |
| Protects traceStream. | |
| std::string | testName |
| Name of test. | |
| TraceLevel | traceLevel |
| Level at which to trace test execution. | |
| FileStatsTarget | statsTarget |
| Output for stats. | |
| StatsTimer | statsTimer |
| Timer for stats collection. | |
| bool | traceStdout |
| Copy trace output to stdout. | |
| bool | traceFile |
| Copy trace output to file. | |
| TestCaseGroup | defaultTests |
| TestCaseGroup | extraTests |
| Static Protected Attributes | |
| static bool | runAll |
| Run all test cases, including the extra tests. | |
| static std::string | runSingle |
| Run only the test case of this name. | |
| Private Member Functions | |
| void | testSqlDateToStr_Ascii () |
| void | testSqlTimeToStr_Ascii () |
| void | appendCharsToUCS2LikeString (string &str, int number, char character) |
| void | testSqlStrToDate_Ascii_Helper (SqlStrToDateConvAction action, uint64_t value, char const *const src, int len, bool errorExpected) |
| void | testSqlStrToDate_Ascii () |
| void | testLocalTime () |
| void | testUniversalTime () |
| string | UnicodeToPrintable (const UnicodeString &s) |
Detailed Description
Definition at line 63 of file SqlDateTest.cpp.
Constructor & Destructor Documentation
| SqlDateTest::SqlDateTest | ( | | ) | [inline, explicit] | | ------------------------ | - | | - | -------------------- |
| virtual SqlDateTest::~SqlDateTest | ( | | ) | [inline, virtual] | | ---------------------------------- | - | | - | ------------------- |
Member Function Documentation
| void SqlDateTest::testSqlDateToStr_Ascii | ( | | ) | [private] | | ----------------------------------------- | - | | - | ----------- |
Definition at line 147 of file SqlDateTest.cpp.
References SqlStringBuffer::mStr, ticks_per_day, ticks_per_month, ticks_per_year, and SqlStringBuffer::verify().
Referenced by SqlDateTest().
00148 {
00149 int storage;
00150 int leftbump = 2;
00151 int rightbump = 2;
00152
00153 SqlStringBuffer s1(
00154 10, 10,
00155 0, 0,
00156 'x', ' ',
00157 leftbump, rightbump);
00158
00159 storage = 10;
00160 SqlDateToStr<1,1,SQLDATE>(s1.mStr, storage, 0);
00161 BOOST_CHECK(s1.verify());
00162 SqlDateToStr<1,1,SQLDATE>(s1.mStr, storage, ticks_per_day);
00163 BOOST_CHECK(s1.verify());
00164 SqlDateToStr<1,1,SQLDATE>(s1.mStr, storage, ticks_per_month);
00165 BOOST_CHECK(s1.verify());
00166
00167 int size, leftpad, rightpad;
00168 for (storage = 5; storage <= 15; storage++) {
00169 for (size = 0; size <= storage; size++) {
00170 for (leftpad = 0; leftpad <= storage - size; leftpad++) {
00171 rightpad = (storage - size) - leftpad;
00172
00173 SqlStringBuffer t(
00174 storage, size,
00175 leftpad, rightpad,
00176 'x', ' ',
00177 leftbump, rightbump);
00178
00179 bool caught = false;
00180 try {
00181 SqlDateToStr<1,1,SQLDATE>(
00182 t.mStr,
00183 storage,
00184 ticks_per_year
00185 + size * ticks_per_month
00186 + storage * ticks_per_day);
00187 } catch (const char *str) {
00188 caught = true;
00189 BOOST_CHECK_EQUAL(strcmp(str,"22001"),0);
00190 BOOST_CHECK(t.verify());
00191 BOOST_CHECK(storage < 10);
00192 } catch (...) {
00193 BOOST_CHECK(false);
00194 }
00195 if (!caught) {
00196 BOOST_CHECK(t.verify());
00197
00198 }
00199 }
00200 }
00201 }
00202 }
| void SqlDateTest::testSqlTimeToStr_Ascii | ( | | ) | [private] | | ----------------------------------------- | - | | - | ----------- |
Definition at line 205 of file SqlDateTest.cpp.
References SqlStringBuffer::mStr, ticks_per_hour, ticks_per_minute, ticks_per_sec, and SqlStringBuffer::verify().
Referenced by SqlDateTest().
00206 {
00207 int storage ;
00208 int leftbump = 2;
00209 int rightbump = 2;
00210
00211 SqlStringBuffer s1(
00212 10, 10,
00213 0, 0,
00214 'x', ' ',
00215 leftbump, rightbump);
00216
00217 storage = 10;
00218 SqlDateToStr<1,1,SQLTIME>(s1.mStr, storage, 0);
00219 BOOST_CHECK(s1.verify());
00220 SqlDateToStr<1,1,SQLTIME>(s1.mStr, storage, ticks_per_hour);
00221 BOOST_CHECK(s1.verify());
00222 SqlDateToStr<1,1,SQLTIME>(s1.mStr, storage, 13LL * ticks_per_hour);
00223 BOOST_CHECK(s1.verify());
00224 SqlDateToStr<1,1,SQLTIME>(s1.mStr, storage, 1000*57601000LL);
00225 BOOST_CHECK(s1.verify());
00226
00227
00228 int size, leftpad, rightpad;
00229 for (storage = 5; storage <= 15; storage++) {
00230 for (size = 0; size <= storage; size++) {
00231 for (leftpad = 0; leftpad <= storage - size; leftpad++) {
00232 rightpad = (storage - size) - leftpad;
00233
00234 SqlStringBuffer t(
00235 storage, size,
00236 leftpad, rightpad,
00237 'x', ' ',
00238 leftbump, rightbump);
00239
00240 bool caught = false;
00241 try {
00242 SqlDateToStr<1,1,SQLTIME>(
00243 t.mStr,
00244 storage,
00245 ticks_per_hour
00246 + size * ticks_per_minute
00247 + storage * ticks_per_sec);
00248 } catch (const char *str) {
00249 caught = true;
00250 BOOST_CHECK_EQUAL(strcmp(str,"22001"),0);
00251 BOOST_CHECK(t.verify());
00252 BOOST_CHECK(storage < 10);
00253 } catch (...) {
00254 BOOST_CHECK(false);
00255 }
00256 if (!caught) {
00257 BOOST_CHECK(t.verify());
00258
00259 }
00260 }
00261 }
00262 }
00263 }
| void SqlDateTest::appendCharsToUCS2LikeString | ( | string & | str, |
|---|---|---|---|
| int | number, | ||
| char | character | ||
| ) | [private] |
Definition at line 129 of file SqlDateTest.cpp.
00133 { 00134 int i; 00135 for (i = 0; i < number; i++) { 00136 #ifdef LITTLEENDIAN 00137 str.push_back(character); 00138 str.push_back(0); 00139 #else 00140 str.push_back(0); 00141 str.push_back(character); 00142 #endif 00143 } 00144 }
| void SqlDateTest::testSqlStrToDate_Ascii_Helper | ( | SqlStrToDateConvAction | action, |
|---|---|---|---|
| uint64_t | value, | ||
| char const *const | src, | ||
| int | len, | ||
| bool | errorExpected | ||
| ) | [private] |
Definition at line 268 of file SqlDateTest.cpp.
References IsoStringToDate(), IsoStringToTime(), IsoStringToTimestamp(), StrToDate, StrToTime, and StrToTimestamp.
Referenced by testSqlStrToDate_Ascii().
00275 {
00276 int64_t t = 0;
00277 bool caught = false;
00278
00279 try {
00280 switch (action) {
00281 case StrToDate:
00282 t = IsoStringToDate(src, len);
00283 break;
00284 case StrToTime:
00285 t = IsoStringToTime(src, len);
00286 break;
00287 case StrToTimestamp:
00288 t = IsoStringToTimestamp(src, len);
00289 break;
00290 default:
00291 permAssert(false);
00292 }
00293 } catch (const char *str) {
00294 caught = true;
00295 BOOST_CHECK_EQUAL(strcmp(str, "22007"), 0);
00296 } catch (...) {
00297
00298 BOOST_CHECK(false);
00299 }
00300 BOOST_CHECK_EQUAL(errorExpected, caught);
00301 if (!caught) {
00302 BOOST_CHECK_EQUAL(value, t);
00303 }
00304 }
| void SqlDateTest::testSqlStrToDate_Ascii | ( | | ) | [private] | | ----------------------------------------- | - | | - | ----------- |
Definition at line 309 of file SqlDateTest.cpp.
References StrToDate, StrToTime, StrToTimestamp, testSqlStrToDate_Ascii_Helper(), ticks_per_hour, ticks_per_minute, and ticks_per_sec.
Referenced by SqlDateTest().
00310 {
00311 int64_t oct2k = 972086400000LL;
00312 testSqlStrToDate_Ascii_Helper(
00313 StrToDate, oct2k, "2000-10-21", 10, false);
00314 testSqlStrToDate_Ascii_Helper(
00315 StrToDate, oct2k, " 2000-10-21 ", 14, false);
00316 testSqlStrToDate_Ascii_Helper(
00317 StrToDate, oct2k, "junk", 4, true);
00318 testSqlStrToDate_Ascii_Helper(
00319 StrToDate, oct2k, "2000-23-23", 10, true);
00320 testSqlStrToDate_Ascii_Helper(
00321 StrToDate, oct2k, "2000-2-30", 10, true);
00322
00323 int64_t fourteen21 =
00324 (ticks_per_hour * 14 +
00325 ticks_per_minute * 21 +
00326 ticks_per_sec * 1) / 1000;
00327 testSqlStrToDate_Ascii_Helper(
00328 StrToTime, fourteen21, "14:21:01", 8, false);
00329 testSqlStrToDate_Ascii_Helper(
00330 StrToTime, fourteen21, "14:21:1", 7, false);
00331 testSqlStrToDate_Ascii_Helper(
00332 StrToTime, fourteen21, " 14:21:01 ", 12, false);
00333
00334
00335
00336 testSqlStrToDate_Ascii_Helper(
00337 StrToTime, fourteen21, "12:61:01", 8, true);
00338 testSqlStrToDate_Ascii_Helper(
00339 StrToTime, fourteen21, "junk", 4, true);
00340 testSqlStrToDate_Ascii_Helper(
00341 StrToTime, fourteen21, "12:34", 5, true);
00342
00343 int64_t ts = oct2k + fourteen21;
00344 testSqlStrToDate_Ascii_Helper(
00345 StrToTimestamp, ts, "2000-10-21 14:21:01", 19, false);
00346 testSqlStrToDate_Ascii_Helper(
00347 StrToTimestamp, ts, "2000-10-21 14:21:1", 18, false);
00348
00349
00350
00351 testSqlStrToDate_Ascii_Helper(
00352 StrToTimestamp, ts, " 2000-10-21 14:21:01 ", 23, false);
00353 testSqlStrToDate_Ascii_Helper(
00354 StrToTimestamp, ts, "2000-10-21 27:21:01", 19, true);
00355 testSqlStrToDate_Ascii_Helper(
00356 StrToTimestamp, ts, "2000-10-32 01:21:01", 19, true);
00357 testSqlStrToDate_Ascii_Helper(
00358 StrToTimestamp, ts, "junk", 4, true);
00359 testSqlStrToDate_Ascii_Helper(
00360 StrToTimestamp, ts, "2323-6-25", 9, true);
00361 }
| void SqlDateTest::testLocalTime | ( | | ) | [private] | | ------------------------------- | - | | - | ----------- |
Definition at line 375 of file SqlDateTest.cpp.
References LocalTime(), and LocalTimestamp().
Referenced by SqlDateTest().
00376 { 00377 boost::local_time::time_zone_ptr tzPST( 00378 new boost::local_time::posix_time_zone( 00379 std::string("PST-8PDT,M3.2.0,M11.1.0"))); 00380 boost::local_time::time_zone_ptr tzUTC( 00381 new boost::local_time::posix_time_zone( 00382 std::string("UTC0"))); 00383 boost::local_time::time_zone_ptr tzJST( 00384 new boost::local_time::posix_time_zone( 00385 std::string("JST9"))); 00386 00387 int64_t tPST = LocalTime(tzPST); 00388 int64_t tJST = LocalTime(tzJST); 00389 int64_t tUTC = LocalTime(tzUTC); 00390 int64_t tsPST = LocalTimestamp(tzPST); 00391 int64_t tsJST = LocalTimestamp(tzJST); 00392 int64_t tsUTC = LocalTimestamp(tzUTC); 00393 00394 cout << "LocalTime(PST) = " << tPST << endl; 00395 cout << "LocalTime(JST) = " << tJST << endl; 00396 cout << "LocalTime(UTC) = " << tUTC << endl; 00397 cout << "LocalTimestamp(PST) = " << tsPST << endl; 00398 cout << "LocalTimestamp(JST) = " << tsJST << endl; 00399 cout << "LocalTimestamp(UTC) = " << tsUTC << endl; 00400 }
| void SqlDateTest::testUniversalTime | ( | | ) | [private] | | ----------------------------------- | - | | - | ----------- |
| string SqlDateTest::UnicodeToPrintable | ( | const UnicodeString & | s | ) | [private] |
|---|
Definition at line 111 of file SqlDateTest.cpp.
00111 {
00112 ostringstream o;
00113 int32_t i, length;
00114 char tmp;
00115
00116
00117 length = s.length();
00118 for (i = 0; i < length; ++i) {
00119 tmp = s.charAt(i) & 0xff;
00120 o << i << "=" << tmp << " | ";
00121 }
00122 return o.str();
00123 }
| void TestBase::snooze | ( | uint | nSeconds | ) | [protected, inherited] |
|---|
| void TestBase::readParams | ( | int | argc, |
|---|---|---|---|
| char ** | argv | ||
| ) | [static, inherited] |
Parses the command line.
format: [-v] [-t TEST | -all] {param=val}* [CONFIGFILE | -] Normally, the test program runs the default test cases. With the option "-all", runs the extra test cases as well. With the option "-t TEST", runs only the single test case named TEST. CONFIGFILE is read to load configuration parameters. Configuration parameters can also be set ad hoc, from the command line, as pairs name=val. These take precedence.
Definition at line 108 of file TestBase.cpp.
References TestBase::configMap, ConfigMap::dumpParams(), ConfigMap::isParamSet(), ConfigMap::mergeFrom(), TestBase::paramDictionaryFileName, ConfigMap::readParams(), TestBase::runAll, TestBase::runSingle, ConfigMap::setStringParam(), and verbose.
00109 {
00110 bool verbose = false;
00111 ConfigMap adhocMap;
00112
00113 for (int i = 1; i < argc; ++i) {
00114 std::string arg = argv[i];
00115 if (argv[i][0] == '-') {
00116 if (arg == "-v") {
00117 verbose = true;
00118 } else if (arg == "-") {
00119 configMap.readParams(std::cin);
00120 } else if (arg == "-all") {
00121 runAll = true;
00122 } else if (arg == "-t") {
00123 permAssert(i + 1 < argc);
00124 runSingle = argv[++i];
00125 } else if (arg[1] == 't') {
00126 runSingle = arg.substr(2);
00127 }
00128 } else {
00129 int i = arg.find("=");
00130 if ((0 < i) && (i < arg.size())) {
00131
00132 std::string key = arg.substr(0,i);
00133 std::string val = arg.substr(i + 1);
00134 adhocMap.setStringParam(key,val);
00135 } else {
00136
00137 std::ifstream configFile(arg.c_str());
00138 assert(configFile.good());
00139 configMap.readParams(configFile);
00140 }
00141 }
00142 }
00143 configMap.mergeFrom(adhocMap);
00144
00145
00146
00147 if (.isParamSet(paramDictionaryFileName)) {
00148 std::string dictFileName = "dictWords";
00149 configMap.setStringParam(paramDictionaryFileName,dictFileName);
00150 }
00151
00152 if (verbose) {
00153 configMap.dumpParams(std::cout);
00154 }
00155 }
| TestSuite * TestBase::releaseTestSuite | ( | | ) | [inherited] | | ---------------------------------------------------------------------------------------------- | - | | - | ------------- |
| void TestBase::beforeTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::afterTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::testCaseSetUp | ( | | ) | [virtual, inherited] | | ---------------------------- | - | | - | ---------------------- |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmExecStreamTestBase, LbmLoadBitmapTest, LbmSearchTest, LbmSplicerExecStreamTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, ExecStreamGovernorTest, ExecStreamTestBase, ExecStreamUnitTestBase, ExternalSortExecStreamTest, LhxHashTableTest, LogicalTxnTest, and SnapshotSegmentTestBase.
Definition at line 235 of file TestBase.cpp.
Referenced by ExecStreamTestBase::testCaseSetUp().
| void TestBase::testCaseTearDown | ( | | ) | [virtual, inherited] | | ------------------------------- | - | | - | ---------------------- |
Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmLoadBitmapTest, LbmSearchTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, CacheTestBase, DatabaseTest, ExecStreamTestBase, LhxHashTableTest, RandomAccessFileDeviceTest, and SparseBitmapTest.
Definition at line 239 of file TestBase.cpp.
Referenced by SparseBitmapTest::testCaseTearDown().
| void TestBase::notifyTrace | ( | std::string | source, |
|---|---|---|---|
| TraceLevel | level, | ||
| std::string | message | ||
| ) | [virtual, inherited] |
| TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
|---|
| void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, |
|---|---|---|---|
| std::string | name | ||
| ) | [virtual, inherited] |
| void TraceSource::trace | ( | TraceLevel | level, |
|---|---|---|---|
| std::string | message | ||
| ) | const [inherited] |
| bool TraceSource::isTracing | ( | | ) | const [inline, inherited] | | --------------------------- | - | | - | --------------------------- |
| bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
|---|
| TraceTarget& TraceSource::getTraceTarget | ( | | ) | const [inline, inherited] | | ----------------------------------------------------------------- | - | | - | --------------------------- |
| std::string TraceSource::getTraceSourceName | ( | | ) | const [inline, inherited] | | ------------------------------------------- | - | | - | --------------------------- |
| void TraceSource::setTraceSourceName | ( | std::string const & | n | ) | [inline, inherited] |
|---|
Sets the name of this source.
Useful to construct dynamic names for fine-grained filtering.
Definition at line 136 of file TraceSource.h.
00137 { 00138 name = n; 00139 }
| TraceLevel TraceSource::getMinimumTraceLevel | ( | | ) | const [inline, inherited] | | ------------------------------------------------------------------------------------------------------ | - | | - | --------------------------- |
| void TraceSource::disableTracing | ( | | ) | [inherited] | | -------------------------------- | - | | - | ------------- |
Member Data Documentation
Configuration parameters.
The reason this is static is so that no constructor parameters (which burden virtual bases) are needed.
Definition at line 155 of file TestBase.h.
Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), BTreeTxnTest::BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest::DatabaseTest(), TestOptionsTest::extra(), DatabaseTest::loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCheckpoint(), DatabaseTest::testCreateEmpty(), DatabaseTest::testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), BTreeTxnTest::testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().
The documentation for this class was generated from the following file:
- /home/pub/open/dev/fennel/calctest/SqlDateTest.cpp
