You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2008/01/30 10:47:27 UTC
svn commit: r616702 - in /logging/log4cxx/trunk/src/test/cpp: abts.c
helpers/datetimedateformattestcase.cpp logunit.cpp
Author: carnold
Date: Wed Jan 30 01:47:26 2008
New Revision: 616702
URL: http://svn.apache.org/viewvc?rev=616702&view=rev
Log:
LOGCXX-225: VC 6 tweaks for unit tests
Modified:
logging/log4cxx/trunk/src/test/cpp/abts.c
logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp
logging/log4cxx/trunk/src/test/cpp/logunit.cpp
Modified: logging/log4cxx/trunk/src/test/cpp/abts.c
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/abts.c?rev=616702&r1=616701&r2=616702&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/abts.c (original)
+++ logging/log4cxx/trunk/src/test/cpp/abts.c Wed Jan 30 01:47:26 2008
@@ -386,7 +386,11 @@
initialize();
+#if defined(_MSC_VER)
+ quiet = 1;
+#else
quiet = !isatty(STDOUT_FILENO);
+#endif
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
Modified: logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp?rev=616702&r1=616701&r2=616702&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp Wed Jan 30 01:47:26 2008
@@ -70,7 +70,7 @@
LOGUNIT_TEST( test7 );
LOGUNIT_TEST( test8 );
#endif
- LOGUNIT_TEST_SUITE_END();
+ LOGUNIT_TEST_SUITE_END(DateTimeDateFormatTestCase);
@@ -96,6 +96,7 @@
formatter.format(actual, date, p);
LOGUNIT_ASSERT_EQUAL( expected, actual );
}
+public:
/** Convert 02 Jan 2004 00:00:00 GMT for GMT. */
void test1()
Modified: logging/log4cxx/trunk/src/test/cpp/logunit.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/logunit.cpp?rev=616702&r1=616701&r2=616702&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/logunit.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/logunit.cpp Wed Jan 30 01:47:26 2008
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#if defined(_MSC_VER)
+#pragma warning ( disable: 4786 4231 )
+#endif
#include "logunit.h"
@@ -31,8 +34,11 @@
}
abts_suite* abts_run_suites(abts_suite* suite) {
- LogUnit::SuiteList sorted(LogUnit::getAllSuites());
+ LogUnit::SuiteList sorted(LogUnit::getAllSuites());
+
+#if !defined(_MSC_VER)
std::sort(sorted.begin(), sorted.end(), suite_sort);
+#endif
for(LogUnit::SuiteList::const_iterator iter = sorted.begin();
iter != sorted.end();
@@ -50,14 +56,14 @@
}
using namespace LogUnit;
-
+using namespace std;
TestException::TestException() {}
TestException::TestException(const TestException& src) : std::exception(src) {
}
TestException& TestException::operator=(const TestException& src) {
- std::exception::operator=(src);
+ exception::operator=(src);
return *this;
}
@@ -82,7 +88,7 @@
}
AssertException& AssertException::operator=(const AssertException& src) {
- std::exception::operator=(src);
+ exception::operator=(src);
msg = src.msg;
lineno = src.lineno;
return *this;
@@ -117,6 +123,19 @@
throw TestException();
}
}
+
+template<class Ch>
+static transcode(std::string& dst, const std::basic_string<Ch>& src) {
+ for(std::basic_string<Ch>::const_iterator iter = src.begin();
+ iter != src.end();
+ iter++) {
+ if (*iter <= 0x7F) {
+ dst.append(1, (char) *iter);
+ } else {
+ dst.append(1, '?');
+ }
+ }
+}
#if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_WCHAR_T_API
void TestFixture::assertEquals(const std::wstring expected,
@@ -125,26 +144,9 @@
const char* actualExpr,
int lineno) {
if (expected != actual) {
- std::string exp;
- std::string act;
- for(std::wstring::const_iterator iter = expected.begin();
- iter != expected.end();
- iter++) {
- if (*iter <= 0x7F) {
- exp.append(1, (char) *iter);
- } else {
- exp.append(1, '?');
- }
- }
- for(std::wstring::const_iterator iter = actual.begin();
- iter != actual.end();
- iter++) {
- if (*iter <= 0x7F) {
- act.append(1, (char) *iter);
- } else {
- act.append(1, '?');
- }
- }
+ std::string exp, act;
+ transcode(exp, expected);
+ transcode(act, actual);
abts_str_equal(tc, exp.c_str(), act.c_str(), lineno);
throw TestException();
}
@@ -157,26 +159,9 @@
const char* actualExpr,
int lineno) {
if (expected != actual) {
- std::string exp;
- std::string act;
- for(std::basic_string<UniChar>::const_iterator iter = expected.begin();
- iter != expected.end();
- iter++) {
- if (*iter <= 0x7F) {
- exp.append(1, (char) *iter);
- } else {
- exp.append(1, '?');
- }
- }
- for(std::basic_string<UniChar>::const_iterator iter = actual.begin();
- iter != actual.end();
- iter++) {
- if (*iter <= 0x7F) {
- act.append(1, (char) *iter);
- } else {
- act.append(1, '?');
- }
- }
+ std::string exp, act;
+ transcode(exp, expected);
+ transcode(act, actual);
abts_str_equal(tc, exp.c_str(), act.c_str(), lineno);
throw TestException();
}