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/31 06:35:52 UTC
svn commit: r617006 - in /logging/log4cxx/trunk/src/test/cpp: abts.c
abts.cpp helpers/datetimedateformattestcase.cpp logunit.cpp logunit.h
Author: carnold
Date: Wed Jan 30 21:35:51 2008
New Revision: 617006
URL: http://svn.apache.org/viewvc?rev=617006&view=rev
Log:
LOGCXX-225: Avoid the pain rename abts.c to abts.cpp
Added:
logging/log4cxx/trunk/src/test/cpp/abts.cpp
- copied, changed from r617002, logging/log4cxx/trunk/src/test/cpp/abts.c
Removed:
logging/log4cxx/trunk/src/test/cpp/abts.c
Modified:
logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp
logging/log4cxx/trunk/src/test/cpp/logunit.cpp
logging/log4cxx/trunk/src/test/cpp/logunit.h
Copied: logging/log4cxx/trunk/src/test/cpp/abts.cpp (from r617002, logging/log4cxx/trunk/src/test/cpp/abts.c)
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/abts.cpp?p2=logging/log4cxx/trunk/src/test/cpp/abts.cpp&p1=logging/log4cxx/trunk/src/test/cpp/abts.c&r1=617002&r2=617006&rev=617006&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/abts.c (original)
+++ logging/log4cxx/trunk/src/test/cpp/abts.cpp Wed Jan 30 21:35:51 2008
@@ -20,6 +20,8 @@
#include "abts_tests.h"
#include "testutil.h"
+
+
#define ABTS_STAT_SIZE 6
static char status[ABTS_STAT_SIZE] = {'|', '/', '-', '|', '\\', '-'};
static int curr_char;
@@ -29,6 +31,8 @@
static int list_tests = 0;
const char **testlist = NULL;
+// defined in logunit.cpp
+abts_suite* abts_run_suites(abts_suite*);
static int find_test_name(const char *testname) {
int i;
@@ -101,7 +105,7 @@
end_suite(suite);
}
- subsuite = malloc(sizeof(*subsuite));
+ subsuite = (sub_suite*) malloc(sizeof(*subsuite));
subsuite->num_test = 0;
subsuite->failed = 0;
subsuite->next = NULL;
@@ -115,7 +119,7 @@
}
p = strrchr(suite_name, '.');
if (p) {
- subsuite->name = memcpy(calloc(p - suite_name + 1, 1),
+ subsuite->name = (const char*) memcpy(calloc(p - suite_name + 1, 1),
suite_name, p - suite_name);
}
else {
@@ -129,7 +133,7 @@
subsuite->not_run = 0;
if (suite == NULL) {
- suite = malloc(sizeof(*suite));
+ suite = (abts_suite*) malloc(sizeof(*suite));
suite->head = subsuite;
suite->tail = subsuite;
}
@@ -420,7 +424,7 @@
/* Waste a little space here, because it is easier than counting the
* number of tests listed. Besides it is at most three char *.
*/
- testlist = calloc(argc + 1, sizeof(char *));
+ testlist = (const char**) calloc(argc + 1, sizeof(char *));
for (i = 1; i < argc; i++) {
testlist[i - 1] = argv[i];
}
@@ -435,4 +439,3 @@
}
return rv;
}
-
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=617006&r1=617005&r2=617006&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/helpers/datetimedateformattestcase.cpp Wed Jan 30 21:35:51 2008
@@ -70,7 +70,7 @@
LOGUNIT_TEST( test7 );
LOGUNIT_TEST( test8 );
#endif
- LOGUNIT_TEST_SUITE_END(DateTimeDateFormatTestCase);
+ LOGUNIT_TEST_SUITE_END();
Modified: logging/log4cxx/trunk/src/test/cpp/logunit.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/logunit.cpp?rev=617006&r1=617005&r2=617006&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/logunit.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/logunit.cpp Wed Jan 30 21:35:51 2008
@@ -14,31 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#if defined(_MSC_VER)
-#pragma warning ( disable: 4786 4231 )
-#endif
+#if defined(_MSC_VER)
+#pragma warning ( disable: 4786 4231 )
+#endif
#include "logunit.h"
#include <apr_general.h>
-extern "C" {
void initialize() {
apr_initialize();
}
extern const char** testlist;
-bool suite_sort(const LogUnit::SuiteList::value_type& lhs, const LogUnit::SuiteList::value_type& rhs) {
+static bool suite_sort(const LogUnit::SuiteList::value_type& lhs, const LogUnit::SuiteList::value_type& rhs) {
return lhs.first < rhs.first;
}
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
+#endif
for(LogUnit::SuiteList::const_iterator iter = sorted.begin();
iter != sorted.end();
@@ -53,7 +52,6 @@
apr_terminate();
return suite;
}
-}
using namespace LogUnit;
using namespace std;
@@ -123,19 +121,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, '?');
- }
- }
-}
+
+template<class S>
+static void transcode(std::string& dst, const S& src) {
+ for(typename S::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,
@@ -144,8 +142,8 @@
const char* actualExpr,
int lineno) {
if (expected != actual) {
- std::string exp, act;
- transcode(exp, expected);
+ std::string exp, act;
+ transcode(exp, expected);
transcode(act, actual);
abts_str_equal(tc, exp.c_str(), act.c_str(), lineno);
throw TestException();
@@ -160,8 +158,8 @@
int lineno) {
if (expected != actual) {
std::string exp, act;
- transcode(exp, expected);
- transcode(act, actual);
+ transcode(exp, expected);
+ transcode(act, actual);
abts_str_equal(tc, exp.c_str(), act.c_str(), lineno);
throw TestException();
}
Modified: logging/log4cxx/trunk/src/test/cpp/logunit.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/logunit.h?rev=617006&r1=617005&r2=617006&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/logunit.h (original)
+++ logging/log4cxx/trunk/src/test/cpp/logunit.h Wed Jan 30 21:35:51 2008
@@ -16,13 +16,13 @@
*/
#if !defined(_LOG4CXX_LOGUNIT_H)
-#define _LOG4CXX_LOGUNIT_H
-
-
-#if defined(_MSC_VER)
-#pragma warning (push)
-#pragma warning (disable: 4786 4231)
-#endif
+#define _LOG4CXX_LOGUNIT_H
+
+
+#if defined(_MSC_VER)
+#pragma warning (push)
+#pragma warning (disable: 4786 4231)
+#endif
#include "abts.h"
#include <exception>
@@ -203,7 +203,7 @@
} register ## testName;
-#define LOGUNIT_TEST_SUITE_END(TF) \
+#define LOGUNIT_TEST_SUITE_END() \
}; \
public: \
static void populateSuite() { \
@@ -221,11 +221,11 @@
#define LOGUNIT_ASSERT(x) { if (!(x)) throw LogUnit::AssertException(true, #x, __LINE__); }
#define LOGUNIT_ASSERT_EQUAL(expected, actual) assertEquals(expected, actual, #expected, #actual, __LINE__)
#define LOGUNIT_FAIL(msg) throw LogUnit::AssertException(msg, __LINE__)
-
-
-#if defined(_MSC_VER)
-#pragma warning (pop)
-#endif
+
+
+#if defined(_MSC_VER)
+#pragma warning (pop)
+#endif
#endif