Commit f8ef72e8 authored by jds2's avatar jds2

- modified dtd and xsl files to support inactive suites/tests.

- instrumented entire framework/interfaces for gettext
    (not activated yet, just instrumented source).


git-svn-id: http://svn.code.sf.net/p/cunit/code/trunk@101 f00e6729-6848-4c17-8bfb-678c97c00071
parent 58a586f1
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
*/ */
/* /*
* Contains Interface for console Run tests. * Contains Interface for curses Run tests.
* *
* Aug 2001 Initial implementation. (AK) * Aug 2001 Initial implementation. (AK)
* *
......
/* /*
* CUnit - A Unit testing framework library for C. * CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar * Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair * Copyright (C) 2004-2006 Anil Kumar, Jerry St.Clair
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
*/ */
/* /*
* Contains ASSERT Macro definitions. * ASSERT Macro definitions and general CUnit configuration definitions.
* *
* 09/Aug/2001 ASSERT definitions. (AK) * 09/Aug/2001 ASSERT definitions. (AK)
* *
...@@ -83,7 +83,15 @@ ...@@ -83,7 +83,15 @@
#define CU_UNREFERENCED_PARAMETER(x) (void)x #define CU_UNREFERENCED_PARAMETER(x) (void)x
#endif #endif
#ifdef WIN32 #ifndef CU_MAX
# define CU_MAX(a,b) (((a) >= (b)) ? (a) : (b))
#endif
#ifndef CU_MIN
# define CU_MIN(a,b) (((a) >= (b)) ? (b) : (a))
#endif
#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_)
# ifdef CU_DLL # ifdef CU_DLL
# ifdef CU_BUILD_DLL # ifdef CU_BUILD_DLL
# define CU_EXPORT __declspec(dllexport) # define CU_EXPORT __declspec(dllexport)
...@@ -93,9 +101,13 @@ ...@@ -93,9 +101,13 @@
# else # else
# define CU_EXPORT # define CU_EXPORT
# endif # endif
# ifdef _MSC_VER
# define snprintf _snprintf
# define itoa _itoa
# endif
#else #else
# define CU_EXPORT # define CU_EXPORT
#endif #endif /* WIN32 */
#include "CUError.h" #include "CUError.h"
#include "TestDB.h" /* not needed here - included for user convenience */ #include "TestDB.h" /* not needed here - included for user convenience */
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2006 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
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Internationalization support
*
* 05-May-2006 Initial implementation. (JDS)
*/
/** @file
* Internal CUnit header supporting internationalization of
* CUnit framework & interfaces.
*/
/** @addtogroup Framework
* @{
*/
#ifndef CUNIT_CUNIT_INTL_H_SEEN
#define CUNIT_CUNIT_INTL_H_SEEN
/* activate these when source preparation is complete
#include <libintl.h>
#ifndef _
# define _(String) gettext (String)
#endif
#ifndef gettext_noop
# define gettext_noop(String) String
#endif
#ifndef N_
# define N_(String) gettext_noop (String)
#endif
*/
/* deactivate these when source preparation is complete */
#undef _
#define _(String) (String)
#undef N_
#define N_(String) String
#undef textdomain
#define textdomain(Domain)
#undef bindtextdomain
#define bindtextdomain(Package, Directory)
#endif /* CUNIT_CUNIT_INTL_H_SEEN */
/** @} */
...@@ -281,7 +281,7 @@ CU_pSuite CU_add_suite(const char *strName, ...@@ -281,7 +281,7 @@ CU_pSuite CU_add_suite(const char *strName,
* initialized before calling this function (checked by assertion). * initialized before calling this function (checked by assertion).
* pInit and pClean may be NULL, in which case no corresponding * pInit and pClean may be NULL, in which case no corresponding
* initialization of cleanup function will be called when the suite * initialization of cleanup function will be called when the suite
* is run.<br /><br /> * is run. strName may be empty ("") but may not be NULL.<br /><br />
* *
* The return value is a pointer to the newly-created suite, or * The return value is a pointer to the newly-created suite, or
* NULL if there was a problem with the suite creation or addition. * NULL if there was a problem with the suite creation or addition.
......
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
* 23-Apr-2006 Moved doxygen comments into header. * 23-Apr-2006 Moved doxygen comments into header.
* Added type marker to CU_FailureRecord. * Added type marker to CU_FailureRecord.
* Added support for tracking inactive suites/tests. (JDS) * Added support for tracking inactive suites/tests. (JDS)
*
* 08-May-2006 Moved CU_print_run_results() functionality from
* console/basic test complete handler. (JDS)
*/ */
/** @file /** @file
...@@ -315,6 +318,20 @@ CU_EXPORT CU_pRunSummary CU_get_run_summary(void); ...@@ -315,6 +318,20 @@ CU_EXPORT CU_pRunSummary CU_get_run_summary(void);
* initiates a run using CU_run_all_tests(), CU_run_suite(), or CU_run_test(). * initiates a run using CU_run_all_tests(), CU_run_suite(), or CU_run_test().
*/ */
CU_EXPORT void CU_print_run_results(FILE *file);
/**<
* Prints a summary of the current run to file.
* The run summary presents data for the suites, tests, and assertions
* encountered during the run. The data presented include the number
* of registered, run, passed, failed, and inactive entities for each.
* This function can be called at any time, although the test registry
* must have been initialized and file may not be NULL (both checked by
* assertion).
*
* @param file Pointer to stream to receive the printed summary.
*/
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* Functions for internal & testing use. * Functions for internal & testing use.
*--------------------------------------------------------------------*/ *--------------------------------------------------------------------*/
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* 5-Sep-2004 Added internal test interface. (JDS) * 5-Sep-2004 Added internal test interface. (JDS)
* *
* 17-Apr-2006 Added CU_translated_strlen(). * 17-Apr-2006 Added CU_translated_strlen() and CU_number_width().
* Removed CUNIT_MAX_STRING_LENGTH - dangerous since not enforced. * Removed CUNIT_MAX_STRING_LENGTH - dangerous since not enforced.
* Fixed off-by-1 error in CU_translate_special_characters(), * Fixed off-by-1 error in CU_translate_special_characters(),
* modifying implementation & results in some cases. User can * modifying implementation & results in some cases. User can
...@@ -74,7 +74,7 @@ CU_EXPORT size_t CU_translate_special_characters(const char *szSrc, char *szDest ...@@ -74,7 +74,7 @@ CU_EXPORT size_t CU_translate_special_characters(const char *szSrc, char *szDest
* in an unspecified manner. It is the caller's responsibility to make * in an unspecified manner. It is the caller's responsibility to make
* sure there is sufficient room in szDest to hold the converted string. * sure there is sufficient room in szDest to hold the converted string.
* CU_translated_strlen() may be used to calculate the length of buffer * CU_translated_strlen() may be used to calculate the length of buffer
* required (remembering to add 1 for the terminating \0). * required (remember to add 1 for the terminating \0).
* *
* @param szSrc Source string to convert (non-NULL). * @param szSrc Source string to convert (non-NULL).
* @param szDest Location to hold the converted string (non-NULL). * @param szDest Location to hold the converted string (non-NULL).
...@@ -107,22 +107,28 @@ CU_EXPORT int CU_compare_strings(const char *szSrc, const char *szDest); ...@@ -107,22 +107,28 @@ CU_EXPORT int CU_compare_strings(const char *szSrc, const char *szDest);
CU_EXPORT void CU_trim_left(char *szString); CU_EXPORT void CU_trim_left(char *szString);
/**< /**<
* Trim leading whitespace from the specified string. * Trims leading whitespace from the specified string.
* @param szString The string to trim. * @param szString The string to trim.
*/ */
CU_EXPORT void CU_trim_right(char *szString); CU_EXPORT void CU_trim_right(char *szString);
/**< /**<
* Trim trailing whitespace from the specified string. * Trims trailing whitespace from the specified string.
* @param szString The string to trim. * @param szString The string to trim.
*/ */
CU_EXPORT void CU_trim(char *szString); CU_EXPORT void CU_trim(char *szString);
/**< /**<
* Trim leading and trailing whitespace from the specified string. * Trims leading and trailing whitespace from the specified string.
* @param szString The string to trim. * @param szString The string to trim.
*/ */
CU_EXPORT size_t CU_number_width(int number);
/**<
* Calulates the number of places required to display
* number in decimal.
*/
#ifdef CUNIT_BUILD_TESTS #ifdef CUNIT_BUILD_TESTS
void test_cunit_Util(void); void test_cunit_Util(void);
#endif #endif
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
* none has been supplied. (JDS) * none has been supplied. (JDS)
* *
* 30-Apr-2005 Added notification of failed suite cleanup function. (JDS) * 30-Apr-2005 Added notification of failed suite cleanup function. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/ */
/** @file /** @file
...@@ -58,6 +60,7 @@ ...@@ -58,6 +60,7 @@
#include "Util.h" #include "Util.h"
#include "TestRun.h" #include "TestRun.h"
#include "Automated.h" #include "Automated.h"
#include "CUnit_intl.h"
/*================================================================= /*=================================================================
* Global / Static data definitions * Global / Static data definitions
...@@ -103,7 +106,7 @@ void CU_automated_run_tests(void) ...@@ -103,7 +106,7 @@ void CU_automated_run_tests(void)
} }
if (CUE_SUCCESS != initialize_result_file(f_szTestResultFileName)) { if (CUE_SUCCESS != initialize_result_file(f_szTestResultFileName)) {
fprintf(stderr, "\nERROR - Failed to create/initialize the result file."); fprintf(stderr, "\n%s", _("ERROR - Failed to create/initialize the result file."));
} }
else { else {
/* set up the message handlers for writing xml output */ /* set up the message handlers for writing xml output */
...@@ -118,7 +121,7 @@ void CU_automated_run_tests(void) ...@@ -118,7 +121,7 @@ void CU_automated_run_tests(void)
automated_run_all_tests(NULL); automated_run_all_tests(NULL);
if (CUE_SUCCESS != uninitialize_result_file()) { if (CUE_SUCCESS != uninitialize_result_file()) {
fprintf(stderr, "\nERROR - Failed to close/uninitialize the result files."); fprintf(stderr, "\n%s", _("ERROR - Failed to close/uninitialize the result files."));
} }
} }
} }
...@@ -233,6 +236,7 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_ ...@@ -233,6 +236,7 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_
assert(NULL != pTest); assert(NULL != pTest);
assert(NULL != pSuite); assert(NULL != pSuite);
assert(NULL != pSuite->pName);
assert(NULL != f_pTestResultFile); assert(NULL != f_pTestResultFile);
/* write suite close/open tags if this is the 1st test for this szSuite */ /* write suite close/open tags if this is the 1st test for this szSuite */
...@@ -247,7 +251,7 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_ ...@@ -247,7 +251,7 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_
" <CUNIT_RUN_SUITE> \n" " <CUNIT_RUN_SUITE> \n"
" <CUNIT_RUN_SUITE_SUCCESS> \n" " <CUNIT_RUN_SUITE_SUCCESS> \n"
" <SUITE_NAME> %s </SUITE_NAME> \n", " <SUITE_NAME> %s </SUITE_NAME> \n",
(NULL != pSuite->pName) ? pSuite->pName : ""); pSuite->pName);
f_bWriting_CUNIT_RUN_SUITE = CU_TRUE; f_bWriting_CUNIT_RUN_SUITE = CU_TRUE;
f_pRunningSuite = pSuite; f_pRunningSuite = pSuite;
...@@ -272,7 +276,9 @@ static void automated_test_complete_message_handler(const CU_pTest pTest, ...@@ -272,7 +276,9 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
CU_UNREFERENCED_PARAMETER(pSuite); /* pSuite is not used except in assertion */ CU_UNREFERENCED_PARAMETER(pSuite); /* pSuite is not used except in assertion */
assert(NULL != pTest); assert(NULL != pTest);
assert(NULL != pTest->pName);
assert(NULL != pSuite); assert(NULL != pSuite);
assert(NULL != pSuite->pName);
assert(NULL != f_pTestResultFile); assert(NULL != f_pTestResultFile);
if (NULL != pTempFailure) { if (NULL != pTempFailure) {
...@@ -314,7 +320,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest, ...@@ -314,7 +320,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
" <CONDITION> %s </CONDITION> \n" " <CONDITION> %s </CONDITION> \n"
" </CUNIT_RUN_TEST_FAILURE> \n" " </CUNIT_RUN_TEST_FAILURE> \n"
" </CUNIT_RUN_TEST_RECORD> \n", " </CUNIT_RUN_TEST_RECORD> \n",
(NULL != pTest->pName) ? pTest->pName : "", pTest->pName,
(NULL != pTempFailure->strFileName) ? pTempFailure->strFileName : "", (NULL != pTempFailure->strFileName) ? pTempFailure->strFileName : "",
pTempFailure->uiLineNumber, pTempFailure->uiLineNumber,
szTemp); szTemp);
...@@ -328,7 +334,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest, ...@@ -328,7 +334,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
" <TEST_NAME> %s </TEST_NAME> \n" " <TEST_NAME> %s </TEST_NAME> \n"
" </CUNIT_RUN_TEST_SUCCESS> \n" " </CUNIT_RUN_TEST_SUCCESS> \n"
" </CUNIT_RUN_TEST_RECORD> \n", " </CUNIT_RUN_TEST_RECORD> \n",
(NULL != pTest->pName) ? pTest->pName : ""); pTest->pName);
} }
if (NULL != szTemp) { if (NULL != szTemp) {
...@@ -363,13 +369,14 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord ...@@ -363,13 +369,14 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
fprintf(f_pTestResultFile, fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUMMARY_RECORD> \n" " <CUNIT_RUN_SUMMARY_RECORD> \n"
" <TYPE> Suites </TYPE> \n" " <TYPE> %s </TYPE> \n"
" <TOTAL> %u </TOTAL> \n" " <TOTAL> %u </TOTAL> \n"
" <RUN> %u </RUN> \n" " <RUN> %u </RUN> \n"
" <SUCCEEDED> - NA - </SUCCEEDED> \n" " <SUCCEEDED> - NA - </SUCCEEDED> \n"
" <FAILED> %u </FAILED> \n" " <FAILED> %u </FAILED> \n"
" <INACTIVE> %u </INACTIVE> \n" " <INACTIVE> %u </INACTIVE> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n", " </CUNIT_RUN_SUMMARY_RECORD> \n",
_("Suites"),
pRegistry->uiNumberOfSuites, pRegistry->uiNumberOfSuites,
pRunSummary->nSuitesRun, pRunSummary->nSuitesRun,
pRunSummary->nSuitesFailed, pRunSummary->nSuitesFailed,
...@@ -378,13 +385,14 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord ...@@ -378,13 +385,14 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
fprintf(f_pTestResultFile, fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUMMARY_RECORD> \n" " <CUNIT_RUN_SUMMARY_RECORD> \n"
" <TYPE> Test Cases </TYPE> \n" " <TYPE> %s </TYPE> \n"
" <TOTAL> %u </TOTAL> \n" " <TOTAL> %u </TOTAL> \n"
" <RUN> %u </RUN> \n" " <RUN> %u </RUN> \n"
" <SUCCEEDED> %u </SUCCEEDED> \n" " <SUCCEEDED> %u </SUCCEEDED> \n"
" <FAILED> %u </FAILED> \n" " <FAILED> %u </FAILED> \n"
" <INACTIVE> %u </INACTIVE> \n" " <INACTIVE> %u </INACTIVE> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n", " </CUNIT_RUN_SUMMARY_RECORD> \n",
_("Test Cases"),
pRegistry->uiNumberOfTests, pRegistry->uiNumberOfTests,
pRunSummary->nTestsRun, pRunSummary->nTestsRun,
pRunSummary->nTestsRun - pRunSummary->nTestsFailed, pRunSummary->nTestsRun - pRunSummary->nTestsFailed,
...@@ -394,18 +402,20 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord ...@@ -394,18 +402,20 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
fprintf(f_pTestResultFile, fprintf(f_pTestResultFile,
" <CUNIT_RUN_SUMMARY_RECORD> \n" " <CUNIT_RUN_SUMMARY_RECORD> \n"
" <TYPE> Assertions </TYPE> \n" " <TYPE> %s </TYPE> \n"
" <TOTAL> %u </TOTAL> \n" " <TOTAL> %u </TOTAL> \n"
" <RUN> %u </RUN> \n" " <RUN> %u </RUN> \n"
" <SUCCEEDED> %u </SUCCEEDED> \n" " <SUCCEEDED> %u </SUCCEEDED> \n"
" <FAILED> %u </FAILED> \n" " <FAILED> %u </FAILED> \n"
" <INACTIVE> -NA- </INACTIVE> \n" " <INACTIVE> %s </INACTIVE> \n"
" </CUNIT_RUN_SUMMARY_RECORD> \n" " </CUNIT_RUN_SUMMARY_RECORD> \n"
" </CUNIT_RUN_SUMMARY> \n", " </CUNIT_RUN_SUMMARY> \n",
_("Assertions"),
pRunSummary->nAsserts, pRunSummary->nAsserts,
pRunSummary->nAsserts, pRunSummary->nAsserts,
pRunSummary->nAsserts - pRunSummary->nAssertsFailed, pRunSummary->nAsserts - pRunSummary->nAssertsFailed,
pRunSummary->nAssertsFailed pRunSummary->nAssertsFailed,
_("n/a")
); );
} }
...@@ -416,6 +426,7 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord ...@@ -416,6 +426,7 @@ static void automated_all_tests_complete_message_handler(const CU_pFailureRecord
static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite) static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite)
{ {
assert(NULL != pSuite); assert(NULL != pSuite);
assert(NULL != pSuite->pName);
assert(NULL != f_pTestResultFile); assert(NULL != f_pTestResultFile);
if (CU_TRUE == f_bWriting_CUNIT_RUN_SUITE) { if (CU_TRUE == f_bWriting_CUNIT_RUN_SUITE) {
...@@ -432,8 +443,8 @@ static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite) ...@@ -432,8 +443,8 @@ static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite)
" <FAILURE_REASON> %s </FAILURE_REASON> \n" " <FAILURE_REASON> %s </FAILURE_REASON> \n"
" </CUNIT_RUN_SUITE_FAILURE> \n" " </CUNIT_RUN_SUITE_FAILURE> \n"
" </CUNIT_RUN_SUITE> \n", " </CUNIT_RUN_SUITE> \n",
(NULL != pSuite->pName) ? pSuite->pName : "", pSuite->pName,
"Suite Initialization Failed"); _("Suite Initialization Failed"));
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
...@@ -443,6 +454,7 @@ static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite) ...@@ -443,6 +454,7 @@ static void automated_suite_init_failure_message_handler(const CU_pSuite pSuite)
static void automated_suite_cleanup_failure_message_handler(const CU_pSuite pSuite) static void automated_suite_cleanup_failure_message_handler(const CU_pSuite pSuite)
{ {
assert(NULL != pSuite); assert(NULL != pSuite);
assert(NULL != pSuite->pName);
assert(NULL != f_pTestResultFile); assert(NULL != f_pTestResultFile);
if (CU_TRUE == f_bWriting_CUNIT_RUN_SUITE) { if (CU_TRUE == f_bWriting_CUNIT_RUN_SUITE) {
...@@ -459,8 +471,8 @@ static void automated_suite_cleanup_failure_message_handler(const CU_pSuite pSui ...@@ -459,8 +471,8 @@ static void automated_suite_cleanup_failure_message_handler(const CU_pSuite pSui
" <FAILURE_REASON> %s </FAILURE_REASON> \n" " <FAILURE_REASON> %s </FAILURE_REASON> \n"
" </CUNIT_RUN_SUITE_FAILURE> \n" " </CUNIT_RUN_SUITE_FAILURE> \n"
" </CUNIT_RUN_SUITE> \n", " </CUNIT_RUN_SUITE> \n",
(NULL != pSuite->pName) ? pSuite->pName : "", pSuite->pName,
"Suite Cleanup Failed"); _("Suite Cleanup Failed"));
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
...@@ -479,8 +491,9 @@ static CU_ErrorCode uninitialize_result_file(void) ...@@ -479,8 +491,9 @@ static CU_ErrorCode uninitialize_result_file(void)
time(&tTime); time(&tTime);
szTime = ctime(&tTime); szTime = ctime(&tTime);
fprintf(f_pTestResultFile, fprintf(f_pTestResultFile,
" <CUNIT_FOOTER> File Generated By CUnit v" CU_VERSION " at %s </CUNIT_FOOTER> \n" " <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_RUN_REPORT>", "</CUNIT_TEST_RUN_REPORT>",
_("File Generated By CUnit v"),
(NULL != szTime) ? szTime : ""); (NULL != szTime) ? szTime : "");
if (0 != fclose(f_pTestResultFile)) { if (0 != fclose(f_pTestResultFile)) {
...@@ -531,17 +544,19 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c ...@@ -531,17 +544,19 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
fprintf(pTestListFile, fprintf(pTestListFile,
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n" " <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_TEXT> %s </CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> \n"
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %u </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> \n" " <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %u </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> \n"
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n", " </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n",
_("Total Number of Suites"),
pRegistry->uiNumberOfSuites); pRegistry->uiNumberOfSuites);
fprintf(pTestListFile, fprintf(pTestListFile,
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n" " <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_TEXT> %s </CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> \n"
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %u </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> \n" " <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %u </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> \n"
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n" " </CUNIT_LIST_TOTAL_SUMMARY_RECORD> \n"
" </CUNIT_LIST_TOTAL_SUMMARY> \n", " </CUNIT_LIST_TOTAL_SUMMARY> \n",
_("Total Number of Test Cases"),
pRegistry->uiNumberOfTests); pRegistry->uiNumberOfTests);
fprintf(pTestListFile, fprintf(pTestListFile,
...@@ -549,6 +564,7 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c ...@@ -549,6 +564,7 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
pSuite = pRegistry->pSuite; pSuite = pRegistry->pSuite;
while (NULL != pSuite) { while (NULL != pSuite) {
assert(NULL != pSuite->pName);
pTest = pSuite->pTest; pTest = pSuite->pTest;
fprintf(pTestListFile, fprintf(pTestListFile,
...@@ -560,22 +576,23 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c ...@@ -560,22 +576,23 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
" <ACTIVE_VALUE> %s </ACTIVE_VALUE> \n" " <ACTIVE_VALUE> %s </ACTIVE_VALUE> \n"
" <TEST_COUNT_VALUE> %u </TEST_COUNT_VALUE> \n" " <TEST_COUNT_VALUE> %u </TEST_COUNT_VALUE> \n"
" </CUNIT_ALL_TEST_LISTING_SUITE_DEFINITION> \n", " </CUNIT_ALL_TEST_LISTING_SUITE_DEFINITION> \n",
(NULL != pSuite->pName) ? pSuite->pName : "", pSuite->pName,
(NULL != pSuite->pInitializeFunc) ? "Yes" : "No", (NULL != pSuite->pInitializeFunc) ? _("Yes") : _("No"),
(NULL != pSuite->pCleanupFunc) ? "Yes" : "No", (NULL != pSuite->pCleanupFunc) ? _("Yes") : _("No"),
(CU_FALSE != pSuite->fActive) ? "Yes" : "No", (CU_FALSE != pSuite->fActive) ? _("Yes") : _("No"),
pSuite->uiNumberOfTests); pSuite->uiNumberOfTests);
fprintf(pTestListFile, fprintf(pTestListFile,
" <CUNIT_ALL_TEST_LISTING_SUITE_TESTS> \n"); " <CUNIT_ALL_TEST_LISTING_SUITE_TESTS> \n");
while (NULL != pTest) { while (NULL != pTest) {
assert(NULL != pTest->pName);
fprintf(pTestListFile, fprintf(pTestListFile,
" <TEST_CASE_DEFINITION> \n" " <TEST_CASE_DEFINITION> \n"
" <TEST_CASE_NAME> %s </TEST_CASE_NAME> \n" " <TEST_CASE_NAME> %s </TEST_CASE_NAME> \n"
" <TEST_ACTIVE_VALUE> %s </TEST_ACTIVE_VALUE> \n" " <TEST_ACTIVE_VALUE> %s </TEST_ACTIVE_VALUE> \n"
" </TEST_CASE_DEFINITION> \n", " </TEST_CASE_DEFINITION> \n",
(NULL != pTest->pName) ? pTest->pName : "", pTest->pName,
(CU_FALSE != pSuite->fActive) ? "Yes" : "No"); (CU_FALSE != pSuite->fActive) ? _("Yes") : _("No"));
pTest = pTest->pNext; pTest = pTest->pNext;
} }
...@@ -591,8 +608,9 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c ...@@ -591,8 +608,9 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
time(&tTime); time(&tTime);
szTime = ctime(&tTime); szTime = ctime(&tTime);
fprintf(pTestListFile, fprintf(pTestListFile,
" <CUNIT_FOOTER> File Generated By CUnit v" CU_VERSION " at %s </CUNIT_FOOTER> \n" " <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_LIST_REPORT>", "</CUNIT_TEST_LIST_REPORT>",
_("File Generated By CUnit v"),
(NULL != szTime) ? szTime : ""); (NULL != szTime) ? szTime : "");
if (0 != fclose(pTestListFile)) { if (0 != fclose(pTestListFile)) {
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
* 8-Jan-2005 Fixed reporting bug (bug report cunit-Bugs-1093861). (JDS) * 8-Jan-2005 Fixed reporting bug (bug report cunit-Bugs-1093861). (JDS)
* *
* 30-Apr-2005 Added notification of suite cleanup failure. (JDS) * 30-Apr-2005 Added notification of suite cleanup failure. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/ */
/** @file /** @file
...@@ -45,6 +47,7 @@ ...@@ -45,6 +47,7 @@
#include "Util.h" #include "Util.h"
#include "TestRun.h" #include "TestRun.h"
#include "Basic.h" #include "Basic.h"
#include "CUnit_intl.h"
/*================================================================= /*=================================================================
* Global/Static Definitions * Global/Static Definitions
...@@ -77,7 +80,7 @@ CU_ErrorCode CU_basic_run_tests(void) ...@@ -77,7 +80,7 @@ CU_ErrorCode CU_basic_run_tests(void)
if (NULL == CU_get_registry()) { if (NULL == CU_get_registry()) {
if (CU_BRM_SILENT != f_run_mode) if (CU_BRM_SILENT != f_run_mode)
fprintf(stderr, "\n\nFATAL ERROR - Test registry is not initialized.\n"); fprintf(stderr, "\n\n%s\n", _("FATAL ERROR - Test registry is not initialized."));
error = CUE_NOREGISTRY; error = CUE_NOREGISTRY;
} }
else if (CUE_SUCCESS == (error = basic_initialize())) else if (CUE_SUCCESS == (error = basic_initialize()))
...@@ -156,8 +159,10 @@ static CU_ErrorCode basic_initialize(void) ...@@ -156,8 +159,10 @@ static CU_ErrorCode basic_initialize(void)
CU_set_error(CUE_SUCCESS); CU_set_error(CUE_SUCCESS);
if (CU_BRM_SILENT != f_run_mode) if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout, "\n\n CUnit - A Unit testing framework for C - Version " CU_VERSION fprintf(stdout, "\n\n %s" CU_VERSION
"\n http://cunit.sourceforge.net/\n\n"); "\n %s\n\n",
_("CUnit - A unit testing framework for C - Version "),
_("http://cunit.sourceforge.net/"));
CU_set_test_start_handler(basic_test_start_message_handler); CU_set_test_start_handler(basic_test_start_message_handler);
CU_set_test_complete_handler(basic_test_complete_message_handler); CU_set_test_complete_handler(basic_test_complete_message_handler);
...@@ -230,13 +235,15 @@ static void basic_test_start_message_handler(const CU_pTest pTest, const CU_pSui ...@@ -230,13 +235,15 @@ static void basic_test_start_message_handler(const CU_pTest pTest, const CU_pSui
assert(NULL != pTest); assert(NULL != pTest);
if (CU_BRM_VERBOSE == f_run_mode) { if (CU_BRM_VERBOSE == f_run_mode) {
assert(NULL != pTest->pName);
if ((NULL == f_pRunningSuite) || (f_pRunningSuite != pSuite)) { if ((NULL == f_pRunningSuite) || (f_pRunningSuite != pSuite)) {
fprintf(stdout, "\nSuite: %s", (NULL != pSuite->pName) ? pSuite->pName : ""); assert(NULL != pSuite->pName);
fprintf(stdout, "\n Test: %s ... ", (NULL != pTest->pName) ? pTest->pName : ""); fprintf(stdout, "\n%s: %s", _("Suite"), pSuite->pName);
fprintf(stdout, "\n %s: %s ...", _("Test"), pTest->pName);
f_pRunningSuite = pSuite; f_pRunningSuite = pSuite;
} }
else { else {
fprintf(stdout, "\n Test: %s ... ", (NULL != pTest->pName) ? pTest->pName : "");