Commit cfb97862 authored by jds2's avatar jds2

- Initial commit of prototype wxWidgets interface & example

- Reworked internal handing of inactive tests/suites in TestRun.c
- Added tracking of elapsed time to test run reporting
- Added message handlers for suite start & completion
- Documentation and internal test updates
- Added new functions to libcunit_dll.def


git-svn-id: http://svn.code.sf.net/p/cunit/code/trunk@103 f00e6729-6848-4c17-8bfb-678c97c00071
parent 3e6f635d
......@@ -41,6 +41,9 @@
*
* 08-May-2006 Moved CU_print_run_results() functionality from
* console/basic test complete handler. (JDS)
*
* 24-May-2006 Added callbacks for suite start and complete events.
* Added tracking/reported of elapsed time. (JDS)
*/
/** @file
......@@ -112,12 +115,16 @@ typedef struct CU_RunSummary
unsigned int nAsserts; /**< Number of assertions tested during run. */
unsigned int nAssertsFailed; /**< Number of failed assertions. */
unsigned int nFailureRecords; /**< Number of failure records generated. */
double ElapsedTime; /**< Elapsed time for run in seconds. */
} CU_RunSummary;
typedef CU_RunSummary* CU_pRunSummary; /**< Pointer to CU_RunSummary. */
/*--------------------------------------------------------------------
* Type Definitions for Message Handlers.
*--------------------------------------------------------------------*/
typedef void (*CU_SuiteStartMessageHandler)(const CU_pSuite pSuite);
/**< Message handler called at the start of a suite. pSuite will not be null. */
typedef void (*CU_TestStartMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite);
/**< Message handler called at the start of a test.
* The parameters are the test and suite being run. The test run is
......@@ -134,6 +141,15 @@ typedef void (*CU_TestCompleteMessageHandler)(const CU_pTest pTest, const CU_pSu
* is considered in progress when the message handler is called.
*/
typedef void (*CU_SuiteCompleteMessageHandler)(const CU_pSuite pSuite,
const CU_pFailureRecord pFailure);
/**< Message handler called at the completion of a suite.
* The parameters are suite being run, plus a pointer to the first failure
* record applicable to this suite. If the suite and it's tests did not
* have any failures, pFailure will be NULL. The test run is considered
* in progress when the message handler is called.
*/
typedef void (*CU_AllTestsCompleteMessageHandler)(const CU_pFailureRecord pFailure);
/**< Message handler called at the completion of a test run.
* The parameter is a pointer to the linked list holding the failure
......@@ -154,10 +170,14 @@ typedef void (*CU_SuiteCleanupFailureMessageHandler)(const CU_pSuite pSuite);
/*--------------------------------------------------------------------
* Get/Set functions for Message Handlers
*--------------------------------------------------------------------*/
CU_EXPORT void CU_set_suite_start_handler(CU_SuiteStartMessageHandler pSuiteStartMessage);
/**< Sets the message handler to call before each suite is run. */
CU_EXPORT void CU_set_test_start_handler(CU_TestStartMessageHandler pTestStartMessage);
/**< Sets the message handler to call before each test is run. */
CU_EXPORT void CU_set_test_complete_handler(CU_TestCompleteMessageHandler pTestCompleteMessage);
/**< Sets the message handler to call after each test is run. */
CU_EXPORT void CU_set_suite_complete_handler(CU_SuiteCompleteMessageHandler pSuiteCompleteMessage);
/**< Sets the message handler to call after each suite is run. */
CU_EXPORT void CU_set_all_test_complete_handler(CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage);
/**< Sets the message handler to call after all tests have been run. */
CU_EXPORT void CU_set_suite_init_failure_handler(CU_SuiteInitFailureMessageHandler pSuiteInitFailureMessage);
......@@ -165,10 +185,14 @@ CU_EXPORT void CU_set_suite_init_failure_handler(CU_SuiteInitFailureMessageHandl
CU_EXPORT void CU_set_suite_cleanup_failure_handler(CU_SuiteCleanupFailureMessageHandler pSuiteCleanupFailureMessage);
/**< Sets the message handler to call when a suite cleanup function returns an error. */
CU_EXPORT CU_SuiteStartMessageHandler CU_get_suite_start_handler(void);
/**< Retrieves the message handler called before each suite is run. */
CU_EXPORT CU_TestStartMessageHandler CU_get_test_start_handler(void);
/**< Retrieves the message handler called before each test is run. */
CU_EXPORT CU_TestCompleteMessageHandler CU_get_test_complete_handler(void);
/**< Retrieves the message handler called after each test is run. */
CU_EXPORT CU_SuiteCompleteMessageHandler CU_get_suite_complete_handler(void);
/**< Retrieves the message handler called after each suite is run. */
CU_EXPORT CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler(void);
/**< Retrieves the message handler called after all tests are run. */
CU_EXPORT CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler(void);
......@@ -236,7 +260,9 @@ CU_EXPORT CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest);
* run statistics (counts of tests, successes, failures)
* will be initialized each time this function is called even
* if it is not successful. Both the suite and test specified
* must be active for the test to be run.
* must be active for the test to be run. The suite is not
* considered to be run, although it may be counted as a failed
* suite if the intialization or cleanup functions fail.
*
* @param pSuite The suite containing the test (non-NULL)
* @param pTest The test to run (non-NULL)
......@@ -302,36 +328,63 @@ CU_EXPORT unsigned int CU_get_number_of_successes(void);
CU_EXPORT unsigned int CU_get_number_of_failures(void);
/**< Retrieves the number of failed assertions during the last run (reset each run). */
CU_EXPORT unsigned int CU_get_number_of_failure_records(void);
/**< Retrieve the number failure records created during the previous run (reset each run).
* Note that this may be more than the number of failed assertions, since failure
* records may also be created for failed suite initialization and cleanup.
/**<
* Retrieves the number failure records created during the previous run (reset each run).
* Note that this may be more than the number of failed assertions, since failure
* records may also be created for failed suite initialization and cleanup.
*/
CU_EXPORT double CU_get_elapsed_time(void);
/**<
* Retrieves the elapsed time for the last run in seconds (reset each run).
* This function will calculate the current elapsed time if the test run has not
* yet completed. This is in contrast to the run summary returned by
* CU_get_run_summary(), for which the elapsed time is not updated until the
* end of the run.
*/
CU_EXPORT CU_pFailureRecord CU_get_failure_list(void);
/**< Retrieves the head of the linked list of failures which occurred during the
* last run (reset each run). Note that the pointer returned is invalidated
* when the client initiates a run using CU_run_all_tests(), CU_run_suite(),
* or CU_run_test().
/**<
* Retrieves the head of the linked list of failures which occurred during the
* last run (reset each run). Note that the pointer returned is invalidated
* when the client initiates a run using CU_run_all_tests(), CU_run_suite(),
* or CU_run_test().
*/
CU_EXPORT CU_pRunSummary CU_get_run_summary(void);
/**< Retrieves the entire run summary for the last test run (reset each run).
* Note that the pFailure pointer in the run summary is invalidated when the client
* initiates a run using CU_run_all_tests(), CU_run_suite(), or CU_run_test().
/**<
* Retrieves the entire run summary for the last test run (reset each run).
* The run counts and stats contained in the run summary are updated
* throughout a test run. Note, however, that the elapsed time is not
* updated until after all suites/tests are run but before the "all tests
* complete" message handler is called (if any). To get the elapsed
* time during a test run, use CU_get_elapsed_time() instead.
*/
CU_EXPORT void CU_print_run_results(FILE *file);
CU_EXPORT char * CU_get_run_results_string(void);
/**<
* Prints a summary of the current run to file.
* Creates a string and fills it with a summary of the current run results.
* 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).
* encountered during the run, as well as the elapsed time. The data
* presented include the number of registered, run, passed, failed, and
* inactive entities for each, as well as the elapsed time. This function
* can be called at any time, although the test registry must have been
* initialized (checked by assertion). The returned string is owned by
* the caller and should be deallocated using CU_FREE(). NULL is returned
* if there is an error allocating the new string.
*
* @param file Pointer to stream to receive the printed summary.
* @return A new string containing the run summary (owned by caller).
*/
CU_EXPORT void CU_print_run_results(FILE *file);
/**<
* Prints a summary of the current run results to file.
* The run summary is the same as returned by CU_get_run_results_string().
* Note that no newlines are printed before or after the report, so any
* positioning must be performed before/after calling this function. The
* report itself extends over several lines broken by '\n' characters.
* file may not be NULL (checked by assertion).
*
* @param file Pointer to stream to receive the printed summary (non-NULL).
*/
/*--------------------------------------------------------------------
* Functions for internal & testing use.
*--------------------------------------------------------------------*/
......
/*
* 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
*/
/*
* wxWidgets gui Interface.
*
* May 2006 Initial implementation. (JDS)
*/
/** @file
* wxWidgets-based gui (user interface).
*/
/** @addtogroup wxWidgets
* @{
*/
#ifndef CUNIT_WXWIDGET_H_SEEN
#define CUNIT_WXWIDGET_H_SEEN
#include "CUnit.h"
#include "TestDB.h"
#ifdef __cplusplus
extern "C" {
#endif
CU_BOOL create_tests(void);
CU_BOOL destroy_tests(void);
#ifdef __cplusplus
}
#endif
#endif /* CUNIT_WXWIDGET_H_SEEN */
/** @} */
......@@ -300,7 +300,9 @@ static void basic_test_complete_message_handler(const CU_pTest pTest,
static void basic_all_tests_complete_message_handler(const CU_pFailureRecord pFailure)
{
CU_UNREFERENCED_PARAMETER(pFailure); /* not used in basic interface */
printf("\n\n");
CU_print_run_results(stdout);
printf("\n");
}
/*------------------------------------------------------------------------*/
......
......@@ -661,7 +661,9 @@ static void console_test_complete_message_handler(const CU_pTest pTest,
static void console_all_tests_complete_message_handler(const CU_pFailureRecord pFailure)
{
CU_UNREFERENCED_PARAMETER(pFailure); /* not used in console interface */
printf("\n\n");
CU_print_run_results(stdout);
printf("\n");
}
/*------------------------------------------------------------------------*/
......
......@@ -1029,17 +1029,13 @@ CU_pTest CU_get_test_by_index(unsigned int index, CU_pSuite pSuite)
#include "test_cunit.h"
static int sfunc1(void)
{
return 0;
}
{ return 0; }
static void test1(void)
{
}
{}
static void test2(void)
{
}
{}
/*--------------------------------------------------*/
static void test_CU_initialize_registry(void)
......
This diff is collapsed.
## Process this file with automake to produce Makefile.in
noinst_LTLIBRARIES = libcunitconsole.la
libcunitconsole_la_SOURCES = \
Console.c
/* XPM */
static char * icon_suite_active_xpm[] = {
"32 32 41 1",
" c None",
". c #2D59A3",
"+ c #295193",
"@ c #6E96D8",
"# c #638ED5",
"$ c #2F5DA9",
"% c #305FAC",
"& c #3161B1",
"* c #3263B4",
"= c #3366B9",
"- c #3467BC",
"; c #356AC1",
"> c #9FB9E5",
", c #AAC1E8",
"' c #B3C8EB",
") c #B9CDED",
"! c #BED0EE",
"~ c #C6D6F0",
"{ c #CBD9F1",
"] c #D2DFF4",
"^ c #DAE5F6",
"/ c #E1E9F7",
"( c #E5EDF9",
"_ c #EAF0FA",
": c #EDF2FB",
"< c #F0F5FC",
"[ c #F5F8FD",
"} c #FAFCFE",
"| c #FDFEFF",
"1 c #98B5E4",
"2 c #90AFE2",
"3 c #AEC5EA",
"4 c #F7F9FD",
"5 c #89A9DF",
"6 c #7FA2DD",
"7 c #779DDB",
"8 c #5D89D3",
"9 c #5584D1",
"0 c #4A7CCE",
"a c #4075CC",
"b c #3A70CA",
" ",
" ",
" ",
" ",
" ",
" ",
" ......+ ",
" .@@@@@#$ ",
" .@@@@@@@. ",
" .$%%%&&*==-----;;;;. ",
" .>,')!~{]^/(_:<[}||. ",
" .1>,')!~{]^/(_:<[}|. ",
" .21>,3)!~{]^/(_:<[4. ",
" .521>,3)!~{]^/(_:<[. ",
" .6521>,3)!~{]^/(_:<. ",
" .76521>,3)!~{]^/(_:. ",
" .@76521>,3)!~{]^/(_. ",
" .#@76521>,3'!~{]^/(. ",
" .8#@76521>,3'!~{]^/. ",
" .98#@76521>,3'!~{]^. ",
" .098#@76521>,3'!~{]. ",
" .a098#@76521>,3'!~{. ",
" .ba098#@76521>,3'!~. ",
" ...................& ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static char * icon_suite_active_open_xpm[] = {
"32 32 41 1",
" c None",
". c #274D8B",
"+ c #295193",
"@ c #6E96D8",
"# c #5D89D3",
"$ c #3569BF",
"% c #2D59A3",
"& c #2F5DA9",
"* c #5584D1",
"= c #305FAC",
"- c #779DDB",
"; c #7FA2DD",
"> c #85A7DF",
", c #89A9DF",
"' c #90AFE2",
") c #B3C8EB",
"! c #D2DFF4",
"~ c #DAE5F6",
"{ c #E1E9F7",
"] c #E5EDF9",
"^ c #EAF0FA",
"/ c #F0F5FC",
"( c #F5F8FD",
"_ c #FAFCFE",
": c #FDFEFF",
"< c #3161B1",
"[ c #98B5E4",
"} c #9FB9E5",
"| c #AAC1E8",
"1 c #B9CDED",
"2 c #BED0EE",
"3 c #C6D6F0",
"4 c #CEDCF2",
"5 c #4075CC",
"6 c #356AC1",
"7 c #638ED5",
"8 c #E7EEF9",
"9 c #3366B9",
"0 c #4A7CCE",
"a c #CBD9F1",
"b c #214279",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ......+ ",
" +@@@@@#. ",
" +@@@@@@$. ",
" +@@@@@@@%++++++++++& ",
" +@@@@@@@@@@@@@@@@@@& ",
" +@@@@@@@@@@@@@@@@@@& ",
" +@@*&&&&&&&&&&&&&&&&&&& ",
" +@@=#-;>,')!~{]^/((_::< ",
" +@@+[}|)1234!~{]^/((_1& ",
" +@56'[}|)1234!~{]^/((& ",
" +@=7,'[}|)1234!~{8^/(& ",
" +@+-;,'[}|)1234!~{8^4& ",
" +59@-;,'[}|)1234!~{8& ",
" +=07@-;,'[}|)1234!~{& ",
" ++*#7@-;,'[}|)1234!a& ",
" b=0*#7@-;,'[}|)1234& ",
" b$50*#7@-;,'[}|)123& ",
" b..................& ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static char * icon_suite_inactive_xpm[] = {
"32 32 5 1",
" c None",
". c #000000",
"+ c #8DA0B9",
"@ c #8399B4",
"# c #800000",
" ",
" ",
" ",
" ",
" ",
" ",
" ....... ",
" .+++++@. ",
" .+++++++. ",
" .................... ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .##################. ",
" .................... ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static char * icon_suite_inactive_open_xpm[] = {
"32 32 4 1",
" c None",
". c #000000",
"+ c #8DA0B9",
"@ c #800000",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ....... ",
" .+++++.. ",
" .++++++.. ",
" .+++++++............ ",
" .++++++++++++++++++. ",
" .++++++++++++++++++. ",
" .++.................... ",
" .++.@@@@@@@@@@@@@@@@@@. ",
" .++.@@@@@@@@@@@@@@@@@@. ",
" .+..@@@@@@@@@@@@@@@@@.. ",
" .+.@@@@@@@@@@@@@@@@@@. ",
" .+.@@@@@@@@@@@@@@@@@@. ",
" ...@@@@@@@@@@@@@@@@@.. ",
" ..@@@@@@@@@@@@@@@@@@. ",
" ..@@@@@@@@@@@@@@@@@@. ",
" ..@@@@@@@@@@@@@@@@@.. ",
" .@@@@@@@@@@@@@@@@@@. ",
" .................... ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static char * icon_test_active_xpm[] = {
"32 32 41 1",
" c None",
". c #4B82A8",
"+ c #74A1BD",
"@ c #6B97B6",
"# c #5896BE",
"$ c #538BB1",
"% c #4388B4",
"& c #4381AA",
"* c #D7E0E9",
"= c #7FA6C0",
"- c #D1E5F5",
"; c #CAE1F3",
"> c #C3DDF1",
", c #BCD9EF",
"' c #AFD1EC",
") c #A5CCEA",
"! c #97C4E7",
"~ c #85BBE2",
"{ c #71B2DE",
"] c #71A8D1",
"^ c #4B8EBF",
"/ c #E6EAF1",
"( c #DAEAF7",
"_ c #619BC4",
": c #F1F4F7",
"< c #DEEDF8",
"[ c #87ABC3",
"} c #E5F0F9",
"| c #76BAE2",
"1 c #63B3DE",
"2 c #54A6D8",
"3 c #E9F3FA",
"4 c #FAFCFE",
"5 c #EFF6FC",
"6 c #7AC4E5",
"7 c #8FB0C3",
"8 c #F4F9FD",
"9 c #B6D5EE",
"0 c #F7FBFD",
"a c #FDFDFE",
"b c #FFFFFF",
" ",
" ",
" ",
" ",
" ",
" .+++@@##$$%&* ",
" =-;>,')!!~{]^/ ",
" =(-;>,')!!~]!_: ",
" =<(-;>,')!!];!_: ",
" [}<||111121]3;!+ ",
" [3}<(-;>,')]43;![ ",
" [53}<(-;>,']]]]]& ",
" [556|||1111122!~$ ",
" 78553}<(-;>,9)!!$ ",
" 708553}<(-;>,9)!# ",
" 7006666|||11119)# ",
" 74008553}<(-;>,9@ ",
" 744008553}<(-;>,@ ",
" 7a46666666|||1;>+ ",
" 7aa44008553}<(-;+ ",
" 7baa44008553}<(-+ ",
" 7bb6666666666|<(= ",
" 7bbbaa44008553}<= ",
" 7bbbbaa44008553}= ",
" 7bbbbbaa44008553[ ",
" 7bbbbbbaa4400855[ ",
" 77777777777777[[7 ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static char * icon_test_active_suite_inactive_xpm[] = {
"32 32 40 1",
" c None",
". c #000000",
"+ c #4B82A8",
"@ c #74A1BD",
"# c #6B97B6",
"$ c #5896BE",
"% c #538BB1",
"& c #4388B4",
"* c #4381AA",
"= c #D7E0E9",
"- c #7FA6C0",
"; c #D1E5F5",
"> c #CAE1F3",
", c #C3DDF1",
"' c #BCD9EF",
") c #AFD1EC",
"! c #A5CCEA",
"~ c #97C4E7",
"{ c #85BBE2",
"] c #71B2DE",
"^ c #71A8D1",
"/ c #4B8EBF",
"( c #E6EAF1",
"_ c #DAEAF7",
": c #619BC4",
"< c #F1F4F7",
"[ c #76BAE2",
"} c #63B3DE",
"| c #54A6D8",
"1 c #E9F3FA",
"2 c #87ABC3",
"3 c #FAFCFE",
"4 c #EFF6FC",
"5 c #8FB0C3",
"6 c #F4F9FD",
"7 c #F7FBFD",
"8 c #B6D5EE",
"9 c #7AC4E5",
"0 c #FDFDFE",
"a c #FFFFFF",
" ",
" ",
" ",
" ",
" . . ",
" ... +@@@##$$%%&*= ... ",
" ...-;>,')!~~{]^/( ... ",
" ..._;>,')!~~{^~:< ... ",
" ..._;>,')!~~^>~:... ",
" ...[[}}}}|}^1>... ",
" 2..._;>,')!^3...2 ",
" 24..._;>,')^...^* ",
" 244...[}}}}...~{% ",
" 5644..._;>...!~~% ",
" 57644..._...'8!~$ ",
" 577999.....}}}8!$ ",
" 5377644..._;>,'8# ",
" 533776....._;>,'# ",
" 50399...9...[}>,@ ",
" 5003...644..._;>@ ",
" 5a0...77644..._;@ ",
" 5a...9999999..._- ",
" 5...003377644...- ",
" ...aa003377644... ",
" ...aaaa003377644... ",
" ...aaaaaa003377644... ",
" ...55555555555555225... ",
" ... ... ",
" . . ",
" ",
" ",
" "};
/* XPM */
static char * icon_test_inactive_xpm[] = {
"32 32 15 1",
" c None",
". c #000000",
"+ c #C00000",
"@ c #4B8EBF",
"# c #97C4E7",
"$ c #619BC4",
"% c #CAE1F3",
"& c #76BAE2",
"* c #63B3DE",
"= c #54A6D8",
"- c #E9F3FA",
"; c #74A1BD",
"> c #FAFCFE",
", c #87ABC3",
"' c #7AC4E5",
" ",
" ",
" ",
" ",
" ",
" ............. ",
" .++++++++++.@. ",
" .++++++++++.#$. ",
" .++++++++++.%#$. ",
" .++&&****=*.-%#; ",
" .++++++++++.>-%#, ",
" .++++++++++...... ",
" .++'&&&*****==++. ",
" .+++++++++++++++. ",
" .+++++++++++++++. ",
" .++''''&&&****++. ",
" .+++++++++++++++. ",
" .+++++++++++++++. ",
" .++'''''''&&&*++. ",
" .+++++++++++++++. ",
" .+++++++++++++++. ",
" .++''''''''''&++. ",
" .+++++++++++++++. ",
" .+++++++++++++++. ",
" .+++++++++++++++. ",
" .+++++++++++++++. ",
" ................. ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static char * icon_test_inactive_suite_inactive_xpm[] = {
"32 32 13 1",
" c None",
". c #000000",
"+ c #C00000",
"@ c #4B8EBF",
"# c #97C4E7",
"$ c #619BC4",
"% c #CAE1F3",
"& c #76BAE2",
"* c #63B3DE",
"= c #54A6D8",
"- c #E9F3FA",
"; c #87ABC3",
"> c #7AC4E5",
" ",
" ",
" ",
" . . ",
" ... ... ",
" ................ ... ",
" ...++++++++++.@. ... ",
" ...+++++++++.#$.... ",
" ...++++++++.%#... ",
" ....&****=*.-... ",
" .+...++++++....#; ",
" .++...+++++...... ",
" .++>...***...=++. ",
" .++++...+...++++. ",
" .+++++.....+++++. ",
" .++>>>>...****++. ",