Author: tschoening
Date: Wed Feb 19 05:39:50 2014
New Revision: 1569635
URL: http://svn.apache.org/r1569635
Log:
LOGCXX-425: exceptions in CachedDateFormatTestCase after LOGCXX-420
Modified:
incubator/log4cxx/trunk/src/changes/changes.xml
incubator/log4cxx/trunk/src/main/cpp/cacheddateformat.cpp
incubator/log4cxx/trunk/src/test/cpp/helpers/cacheddateformattestcase.cpp
Modified: incubator/log4cxx/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/changes/changes.xml?rev=1569635&r1=1569634&r2=1569635&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/changes/changes.xml (original)
+++ incubator/log4cxx/trunk/src/changes/changes.xml Wed Feb 19 05:39:50 2014
@@ -84,6 +84,7 @@
<action issue="LOGCXX-422" type="fix">Regression of
LOGCXX-420</action>
<action issue="LOGCXX-423" type="fix">Repair autogen
script warnings</action>
<action issue="LOGCXX-424" type="fix">liblog4cxx.pc.in
should reflect dependency on apr-1, apr-1-util</action>
+ <action issue="LOGCXX-425" type="fix">exceptions in
CachedDateFormatTestCase after LOGCXX-420</action>
<action type="change">Behavior of
StringHelper::startsWith and endsWith synced</action>
<action type="change">Documented C (class) and M
(method) log format keywords.</action>
Modified: incubator/log4cxx/trunk/src/main/cpp/cacheddateformat.cpp
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/cacheddateformat.cpp?rev=1569635&r1=1569634&r2=1569635&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/cacheddateformat.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/cacheddateformat.cpp Wed Feb 19
05:39:50 2014
@@ -139,31 +139,16 @@ int CachedDateFormat::findMillisecondSta
size_t magicLength = magicString.length();
size_t overlapping =
magicString.find(plusMagic[i]);
int possibleRetVal = i - overlapping;
-
-wprintf(L"formatted: %s\n", formatted.c_str());
-wprintf(L"formattedMillis: %s\n", formattedMillis.c_str());
-wprintf(L"magicString: %s\n", magicString.c_str());
-wprintf(L"plusMagic: %s\n", plusMagic.c_str());
-wprintf(L"plusZero: %s\n", plusZero.c_str());
-
-printf("i: %i\n", i);
-printf("formatted.length(): %i\n", formatted.length());
-printf("overlapping: %i\n", overlapping);
-printf("possibleRetVal: %i\n", possibleRetVal);
-
-printf("1: %i\n", regionMatches(magicString, 0, plusMagic, possibleRetVal,
magicLength));
-printf("2: %i\n", regionMatches(formattedMillis, 0, formatted, possibleRetVal,
magicLength));
-printf("3: %i\n", regionMatches(zeroString, 0, plusZero, possibleRetVal,
magicLength));
-printf("4: %i\n", formatted.length() == possibleRetVal + magicLength);
-printf("5: %i\n", plusZero.compare(possibleRetVal + magicLength,
LogString::npos, plusMagic, possibleRetVal + magicLength, LogString::npos) ==
0);
-
if (plusZero.length() == formatted.length()
&& regionMatches(magicString, 0, plusMagic,
possibleRetVal, magicLength)
&& regionMatches(formattedMillis, 0, formatted,
possibleRetVal, magicLength)
&& regionMatches(zeroString, 0, plusZero,
possibleRetVal, magicLength)
- /*&& (formatted.length() == possibleRetVal + magicLength
+ // The following will and should fail for patterns with more
than one SSS because
+ // we only seem to be able to change one SSS in e.g. format and
need to reformat the
+ // whole string in other cases.
+ && (formatted.length() == possibleRetVal + magicLength
|| plusZero.compare(possibleRetVal + magicLength,
- LogString::npos, plusMagic, possibleRetVal +
magicLength, LogString::npos) == 0)*/) {
+ LogString::npos, plusMagic, possibleRetVal +
magicLength, LogString::npos) == 0)) {
return possibleRetVal;
} else {
return UNRECOGNIZED_MILLISECONDS;
Modified:
incubator/log4cxx/trunk/src/test/cpp/helpers/cacheddateformattestcase.cpp
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/test/cpp/helpers/cacheddateformattestcase.cpp?rev=1569635&r1=1569634&r2=1569635&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/test/cpp/helpers/cacheddateformattestcase.cpp
(original)
+++ incubator/log4cxx/trunk/src/test/cpp/helpers/cacheddateformattestcase.cpp
Wed Feb 19 05:39:50 2014
@@ -571,10 +571,11 @@ void test17() {
LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("00:00:00,120 00:00:00,120"),
s);
s.erase(s.begin(), s.end());
-printf("test17 1\n");
+ int msStart = CachedDateFormat::findMillisecondStart(jul2, s,
simpleFormat, p);
+ LOGUNIT_ASSERT_EQUAL((int) CachedDateFormat::UNRECOGNIZED_MILLISECONDS,
msStart);
+
cachedFormat->format(s, jul2, p);
LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("00:00:00,120 00:00:00,120"),
s) ;
-printf("test17 2\n");
int maxValid = CachedDateFormat::getMaximumCacheValidity(badPattern);
LOGUNIT_ASSERT_EQUAL(1000, maxValid);
@@ -582,19 +583,15 @@ printf("test17 2\n");
// Test overlapping millis with a magic string from CachedDateFormat for
LOGCXX-420.
s.clear();
jul2 += 286000;
-printf("test17 3\n");
cachedFormat->format(s, jul2, p);
- int msStart = CachedDateFormat::findMillisecondStart(jul2, s,
simpleFormat, p);
- LOGUNIT_ASSERT_EQUAL(9, msStart);
-printf("test17 4\n");
+ msStart = CachedDateFormat::findMillisecondStart(jul2, s, simpleFormat, p);
+ LOGUNIT_ASSERT_EQUAL((int) CachedDateFormat::UNRECOGNIZED_MILLISECONDS,
msStart);
s.clear();
jul2 += 203000;
-printf("test17 5\n");
cachedFormat->format(s, jul2, p);
msStart = CachedDateFormat::findMillisecondStart(jul2, s, simpleFormat, p);
- LOGUNIT_ASSERT_EQUAL(9, msStart);
-printf("test17 6\n");
+ LOGUNIT_ASSERT_EQUAL((int) CachedDateFormat::UNRECOGNIZED_MILLISECONDS,
msStart);
}
/**