Commit 0885a835 authored by jds2's avatar jds2

100% lint free on gcc (mingw)!


git-svn-id: http://svn.code.sf.net/p/cunit/code/trunk@64 f00e6729-6848-4c17-8bfb-678c97c00071
parent dd9c6b51
......@@ -41,7 +41,7 @@
* Two versions of memory allocation/deallocation are available.
* If compiled with MEMTRACE defined, CUnit keeps track of all
* system allocations & deallocations. The memory record can
* then be reported using CU_DUMP_MEMORY_USAGE. Otherwise,
* then be reported using CU_CREATE_MEMORY_REPORT. Otherwise,
* standard system memory allocation is used without tracing.
*/
/** @addtogroup Framework
......@@ -71,6 +71,8 @@ extern "C" {
/** Reallocate with memory tracking. */
#define CU_REALLOC(x, y) CU_realloc((x), (y), __LINE__, __FILE__)
/** Generate report on tracked memory. */
#define CU_CREATE_MEMORY_REPORT(x) CU_dump_memory_usage((x))
/** Generate report on tracked memory (old macro). */
#define CU_DUMP_MEMORY_USAGE(x) CU_dump_memory_usage((x))
#else
/** Standard calloc() if MEMTRACE not defined. */
......@@ -82,6 +84,8 @@ extern "C" {
/** Standard realloc() if MEMTRACE not defined. */
#define CU_REALLOC(x, y) realloc((x), (y))
/** No-op if MEMTRACE not defined. */
#define CU_CREATE_MEMORY_REPORT(x)
/** No-op if MEMTRACE not defined. */
#define CU_DUMP_MEMORY_USAGE(x)
#endif
......
......@@ -223,7 +223,7 @@ static CU_ErrorCode initialize_result_file(const char* szFilename)
*/
static void automated_test_start_message_handler(const CU_pTest pTest, const CU_pSuite pSuite)
{
(void)pTest; /* not currently used - stop compiler warning */
CU_UNREFERENCED_PARAMETER(pTest); /* not currently used */
assert(f_pTestResultFile);
......@@ -258,8 +258,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
{
CU_pFailureRecord pTempFailure = pFailure;
/* pSuite is not used except in assertion */
(void)pSuite;
CU_UNREFERENCED_PARAMETER(pSuite); /* pSuite is not used except in assertion */
assert(f_pTestResultFile);
......@@ -307,7 +306,7 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
CU_pTestRegistry pRegistry = CU_get_registry();
CU_pRunSummary pRunSummary = CU_get_run_summary();
(void)pFailure; /* not used - quiet compiler warning */
CU_UNREFERENCED_PARAMETER(pFailure); /* not used */
assert(pRegistry);
assert(pRunSummary);
......@@ -321,21 +320,36 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
fprintf(f_pTestResultFile,
" </CUNIT_RESULT_LISTING>\n"
" <CUNIT_RUN_SUMMARY> \n"
" <CUNIT_RUN_SUMMARY> \n");
fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUMMARY_RECORD> \n"
" <TYPE> Suites </TYPE> \n"
" <TOTAL> %u </TOTAL> \n"
" <RUN> %u </RUN> \n"
" <SUCCEEDED> - NA - </SUCCEEDED> \n"
" <FAILED> %u </FAILED> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n",
pRegistry->uiNumberOfSuites,
pRunSummary->nSuitesRun,
pRunSummary->nSuitesFailed
);
fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUMMARY_RECORD> \n"
" <TYPE> Test Cases </TYPE> \n"
" <TOTAL> %u </TOTAL> \n"
" <RUN> %u </RUN> \n"
" <SUCCEEDED> %u </SUCCEEDED> \n"
" <FAILED> %u </FAILED> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n",
pRegistry->uiNumberOfTests,
pRunSummary->nTestsRun,
pRunSummary->nTestsRun - pRunSummary->nTestsFailed,
pRunSummary->nTestsFailed
);
fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUMMARY_RECORD> \n"
" <TYPE> Assertions </TYPE> \n"
" <TOTAL> %u </TOTAL> \n"
......@@ -344,13 +358,6 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
" <FAILED> %u </FAILED> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n"
" </CUNIT_RUN_SUMMARY> \n",
pRegistry->uiNumberOfSuites,
pRunSummary->nSuitesRun,
pRunSummary->nSuitesFailed,
pRegistry->uiNumberOfTests,
pRunSummary->nTestsRun,
pRunSummary->nTestsRun - pRunSummary->nTestsFailed,
pRunSummary->nTestsFailed,
pRunSummary->nAsserts,
pRunSummary->nAsserts,
pRunSummary->nAsserts - pRunSummary->nAssertsFailed,
......@@ -447,17 +454,21 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
"<!DOCTYPE CUNIT_TEST_LIST_REPORT SYSTEM \"CUnit-List.dtd\"> \n"
"<CUNIT_TEST_LIST_REPORT> \n"
" <CUNIT_HEADER/> \n"
" <CUNIT_LIST_TOTAL_SUMMARY> \n"
" <CUNIT_LIST_TOTAL_SUMMARY> \n");
fprintf(pTestListFile,
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n"
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> Total Number of Suites </CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> \n"
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %d </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> \n"
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n"
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n",
pRegistry->uiNumberOfSuites);
fprintf(pTestListFile,
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n"
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> Total Number of Test Cases </CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> \n"
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %d </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> \n"
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n"
" </CUNIT_LIST_TOTAL_SUMMARY> \n",
pRegistry->uiNumberOfSuites,
pRegistry->uiNumberOfTests);
fprintf(pTestListFile,
......
......@@ -321,7 +321,7 @@ static void basic_all_tests_complete_message_handler(const CU_pFailureRecord pFa
CU_pRunSummary pRunSummary = CU_get_run_summary();
CU_pTestRegistry pRegistry = CU_get_registry();
(void)pFailure; /* not used in basic interface - silence warning */
CU_UNREFERENCED_PARAMETER(pFailure); /* not used in basic interface */
assert(pRunSummary);
assert(pRegistry);
......
......@@ -454,9 +454,9 @@ static void console_test_complete_message_handler(const CU_pTest pTest, const CU
* For console interface do nothing. This is useful only for the test
* interface where UI is involved. Just silence compiler warnings.
*/
(void)pTest;
(void)pSuite;
(void)pFailure;
CU_UNREFERENCED_PARAMETER(pTest);
CU_UNREFERENCED_PARAMETER(pSuite);
CU_UNREFERENCED_PARAMETER(pFailure);
}
/*------------------------------------------------------------------------*/
......@@ -468,7 +468,7 @@ static void console_all_tests_complete_message_handler(const CU_pFailureRecord p
CU_pRunSummary pRunSummary = CU_get_run_summary();
CU_pTestRegistry pRegistry = CU_get_registry();
(void)pFailure; /* not used in console interface - silence warning */
CU_UNREFERENCED_PARAMETER(pFailure); /* not used in console interface */
assert(pRunSummary);
assert(pRegistry);
......
......@@ -1001,9 +1001,9 @@ static void curses_test_complete_message_handler(const CU_pTest pTest,
const CU_pFailureRecord pFailure)
{
/* Not used in curses implementation - quiet compiler warning */
(void)pTest;
(void)pSuite;
(void)pFailure;
CU_UNREFERENCED_PARAMETER(pTest);
CU_UNREFERENCED_PARAMETER(pSuite);
CU_UNREFERENCED_PARAMETER(pFailure);
f_uiTestsRun++;
if (CU_get_number_of_tests_failed() != f_uiTestsFailed) {
......@@ -1024,7 +1024,7 @@ static void curses_test_complete_message_handler(const CU_pTest pTest,
static void curses_all_tests_complete_message_handler(const CU_pFailureRecord pFailure)
{
/* Not used in curses implementation - quiet compiler warning */
(void)pFailure;
CU_UNREFERENCED_PARAMETER(pFailure);
f_pCurrentTest = NULL;
f_pCurrentSuite = NULL;
......
......@@ -144,7 +144,7 @@ void CU_cleanup_registry(void)
CU_set_error(CUE_SUCCESS);
CU_destroy_existing_registry(&f_pTestRegistry); /* supposed to handle NULL ok */
CU_clear_previous_results();
CU_DUMP_MEMORY_USAGE(NULL);
CU_CREATE_MEMORY_REPORT(NULL);
}
/*------------------------------------------------------------------------*/
......@@ -715,21 +715,21 @@ void CU_destroy_existing_registry(CU_pTestRegistry* ppRegistry)
*/
CU_pSuite CU_get_suite_by_name(const char* szSuiteName, CU_pTestRegistry pRegistry)
{
CU_pSuite pSuite = NULL;
CU_pSuite pCur = NULL;
CU_pSuite pSuite = NULL;
CU_pSuite pCur = NULL;
assert(pRegistry);
pCur = pRegistry->pSuite;
while (pCur) {
if (!CU_compare_strings(pCur->pName, szSuiteName)) {
pSuite = pCur;
break;
}
pCur = pCur->pNext;
}
pCur = pRegistry->pSuite;
while (pCur) {
if (!CU_compare_strings(pCur->pName, szSuiteName)) {
pSuite = pCur;
break;
}
pCur = pCur->pNext;
}
return pSuite;
return pSuite;
}
/*------------------------------------------------------------------------*/
......@@ -743,21 +743,21 @@ CU_pSuite CU_get_suite_by_name(const char* szSuiteName, CU_pTestRegistry pRegist
*/
CU_pTest CU_get_test_by_name(const char* szTestName, CU_pSuite pSuite)
{
CU_pTest pTest = NULL;
CU_pTest pCur = NULL;
CU_pTest pTest = NULL;
CU_pTest pCur = NULL;
assert(pSuite);
pCur = pSuite->pTest;
while (pCur) {
if (!CU_compare_strings(pCur->pName, szTestName)) {
pTest = pCur;
break;
}
pCur = pCur->pNext;
}
pCur = pSuite->pTest;
while (pCur) {
if (!CU_compare_strings(pCur->pName, szTestName)) {
pTest = pCur;
break;
}
pCur = pCur->pNext;
}
return pTest;
return pTest;
}
/** @} */
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004 Anil Kumar, Jerry St.Clair
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -25,6 +25,16 @@
#include "CUnit.h"
/* WARNING - MAINTENANCE NIGHTMARE AHEAD
*
* If you change any of the tests & suites below, you also need
* to keep track of changes in the result statistics and reflect
* any changes in the result report counts in print_example_results().
*
* Yes, this could have been designed better using a more
* automated mechanism. No, it was not done that way.
*/
/* Suite initialization/cleanup functions */
static int suite_success_init(void) { return 0; }
static int suite_success_clean(void) { return 0; }
......
......@@ -121,8 +121,8 @@ if $(NT)
CCWARN += -Wall ;
CCWARN += -W ;
CCWARN += -pedantic ;
#CCWARN += -Wshadow ;
#CCWARN += -ansi ;
CCWARN += -Wshadow ;
CCWARN += -ansi ;
if $(NODEBUG)
{
......@@ -157,8 +157,8 @@ else if $(OS) = LINUX
CCWARN += -Wall ;
CCWARN += -W ;
CCWARN += -pedantic ;
#CCWARN += -Wshadow ;
#CCWARN += -ansi ;
CCWARN += -Wshadow ;
CCWARN += -ansi ;
if $(NODEBUG)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment