/[ascend]/trunk/test/CUnit/CUError.h
ViewVC logotype

Contents of /trunk/test/CUnit/CUError.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (show annotations) (download) (as text)
Sun Oct 30 01:38:20 2005 UTC (19 years, 6 months ago) by jds
File MIME type: text/x-chdr
File size: 5647 byte(s)
- prototype unit test suite based on CUnit added.
- unit tests for base/generic/general and base/generic/utilites added.
- 2nd manual rework of doxygen documentation in general and utilities.
- bug fixes (mostly general & utilities) found during test development.
- added asc_assert prototype to redirect failures to Asc_Panic() and enable decoupling assertions from NDEBUG.
- some modifications of interface & implementation to facilitate testing.
- utilities/ascPrint & utilities/ascMalloc functions now always included in base libs to minimize recompilation when an interface chooses different options.
1 /*
2 * CUnit - A Unit testing framework library for C.
3 * Copyright (C) 2001 Anil Kumar
4 * Copyright (C) 2004, 2005 Anil Kumar, Jerry St.Clair
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 /*
22 * Contains CUnit error codes which can be used externally.
23 *
24 * Created By : Anil Kumar on ...(in month of Aug 2001)
25 * Last Modified : 09/Aug/2001
26 * Comment : -------
27 * EMail : aksaharan@yahoo.com
28 *
29 * Modified : 02/Oct/2001
30 * Comment : Added proper Eror Codes
31 * EMail : aksaharan@yahoo.com
32 *
33 * Modified : 13-Oct-2001
34 * Comment : Added Error Codes for Duplicate TestGroup and Test
35 * EMail : aksaharan@yahoo.com
36 *
37 * Modified : 3-Aug-2004 (JDS)
38 * Comment : Converted error code macros to an enum, doxygen comments
39 * moved error handing code here, changed file name from Errno.h,
40 * added error codes for file open errors, added error action selection
41 * EMail : jds2@users.sourceforge.net
42 *
43 * Modified : 5-Sep-2004 (JDS)
44 * Comment : Added internal test interface.
45 * EMail : jds2@users.sourceforge.net
46 */
47
48 /** @file
49 * Error handling functions (user interface).
50 * CUnit uses a simple (and conventional) error handling strategy.
51 * Functions that can generate errors set (and usually return) an
52 * error code to indicate the run status. The error code can be
53 * inspected using the CU_get_error() function. A descriptive
54 * error message can be retrieved using CU_get_error_msg().
55 */
56 /** @addtogroup Framework
57 * @{
58 */
59
60 #ifndef CUNIT_CUERROR_H_SEEN
61 #define CUNIT_CUERROR_H_SEEN
62
63 #include <errno.h>
64
65 /*------------------------------------------------------------------------*/
66 /** CUnit error codes.
67 * If codes are added or removed, be sure to make a change to the
68 * error messages in CUError.c/get_error_desc().
69 * @see CU_set_error()
70 * @see CU_get_error()
71 * @see CU_get_error_msg()
72 */
73 typedef enum {
74 /* basic errors */
75 CUE_SUCCESS = 0, /**< No error condition. */
76 CUE_NOMEMORY = 1, /**< Memory allocation failed. */
77
78 /* Test Registry Level Errors */
79 CUE_NOREGISTRY = 10, /**< Test registry not initialized. */
80 CUE_REGISTRY_EXISTS = 11, /**< Attempt to CU_set_registry() without CU_cleanup_registry(). */
81
82 /* Test Suite Level Errors */
83 CUE_NOSUITE = 20, /**< A required CU_pSuite pointer was NULL. */
84 CUE_NO_SUITENAME = 21, /**< Required CU_Suite name not provided. */
85 CUE_SINIT_FAILED = 22, /**< Suite initialization failed. */
86 CUE_SCLEAN_FAILED = 23, /**< Suite cleanup failed. */
87 CUE_DUP_SUITE = 24, /**< Duplicate suite name not allowed. */
88
89 /* Test Case Level Errors */
90 CUE_NOTEST = 30, /**< A required CU_pTest pointer was NULL. */
91 CUE_NO_TESTNAME = 31, /**< Required CU_Test name not provided. */
92 CUE_DUP_TEST = 32, /**< Duplicate test case name not allowed. */
93 CUE_TEST_NOT_IN_SUITE = 33, /**< Test not registered in specified suite. */
94
95 /* File handling errors */
96 CUE_FOPEN_FAILED = 40, /**< An error occurred opening a file. */
97 CUE_FCLOSE_FAILED = 41, /**< An error occurred closing a file. */
98 CUE_BAD_FILENAME = 42, /**< A bad filename was requested (NULL, empty, nonexistent, etc.). */
99 CUE_WRITE_ERROR = 43 /**< An error occurred during a write to a file. */
100 } CU_ErrorCode;
101
102 /*------------------------------------------------------------------------*/
103 /** CUnit error action codes.
104 * These are used to set the action desired when an error
105 * condition is detected in the CUnit framework.
106 * @see CU_set_error_action()
107 * @see CU_get_error_action()
108 */
109 typedef enum {
110 CUEA_IGNORE, /**< Runs should be continued when an error condition occurs (if possible). */
111 CUEA_FAIL, /**< Runs should be stopped when an error condition occurs. */
112 CUEA_ABORT /**< The application should exit() when an error conditions occurs. */
113 } CU_ErrorAction;
114
115 /* Error handling & reporting functions. */
116
117 #include "CUnit.h"
118
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122
123 CU_EXPORT CU_ErrorCode CU_get_error(void);
124 /*@observer@*/
125 CU_EXPORT const char* CU_get_error_msg(void);
126 CU_EXPORT void CU_set_error_action(CU_ErrorAction action);
127 CU_EXPORT CU_ErrorAction CU_get_error_action(void);
128
129 #ifdef CUNIT_BUILD_TESTS
130 void test_cunit_CUError(void);
131 #endif
132
133 /* Internal function - users should not generally call this function */
134 void CU_set_error(CU_ErrorCode error);
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #ifdef USE_DEPRECATED_CUNIT_NAMES
141 /** Deprecated (version 1). @deprecated Use CU_get_error_msg(). */
142 #define get_error() CU_get_error_msg()
143 #endif /* USE_DEPRECATED_CUNIT_NAMES */
144
145 #endif /* CUNIT_CUERROR_H_SEEN */
146 /** @} */

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22