CUnit Programmers Reference  3.0
CUError.h
Go to the documentation of this file.
1 /*
2  * CUnit - A Unit testing framework library for C.
3  * Copyright (C) 2001 Anil Kumar
4  * Copyright (C) 2004-2006 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  * Aug 2001 Initial implementation. (AK)
25  *
26  * 02/Oct/2001 Added proper Eror Codes. (AK)
27  *
28  * 13-Oct-2001 Added Error Codes for Duplicate TestGroup and Test. (AK)
29  *
30  * 03-Aug-2004 Converted error code macros to an enum, doxygen comments, moved
31  * error handing code here, changed file name from Errno.h, added
32  * error codes for file open errors, added error action selection. (JDS)
33  *
34  * 05-Sep-2004 Added internal test interface. (JDS)
35  */
36 
49 #ifndef CUNIT_CUERROR_H_SEEN
50 #define CUNIT_CUERROR_H_SEEN
51 
52 #include <errno.h>
53 
54 /*------------------------------------------------------------------------*/
62 typedef enum {
63  /* basic errors */
67  /* Test Registry Level Errors */
71  /* Test Suite Level Errors */
72  CUE_NOSUITE = 20,
79  /* Test Case Level Errors */
80  CUE_NOTEST = 30,
82  CUE_DUP_TEST = 32,
86  /* File handling errors */
90  CUE_WRITE_ERROR = 43
92 
93 /*------------------------------------------------------------------------*/
100 typedef enum CU_ErrorAction {
103  CUEA_ABORT
105 
106 /* Error handling & reporting functions. */
107 
108 #include "CUnit/CUnit.h"
109 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
114 CU_EXPORT CU_ErrorCode CU_get_error(void);
128 CU_EXPORT const char* CU_get_error_msg(void);
143 CU_EXPORT void CU_set_error_action(CU_ErrorAction action);
159 CU_EXPORT CU_ErrorAction CU_get_error_action(void);
169 #ifdef CUNIT_BUILD_TESTS
170 void test_cunit_CUError(void);
171 #endif
172 
173 /* Internal function - users should not generally call this function */
174 CU_EXPORT void CU_set_error(CU_ErrorCode error);
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #ifdef USE_DEPRECATED_CUNIT_NAMES
195 #define get_error() CU_get_error_msg()
196 #endif /* USE_DEPRECATED_CUNIT_NAMES */
197 
198 #endif /* CUNIT_CUERROR_H_SEEN */
CU_EXPORT CU_ErrorAction CU_get_error_action(void)
Retrieves the current framework error action code.
Definition: CUError.c:98
CU_ErrorAction
CUnit error action codes.
Definition: CUError.h:100
CU_EXPORT void CU_set_error(CU_ErrorCode error)
Sets the CUnit framework error code.
Definition: CUError.c:63
CU_ErrorCode
CUnit error codes.
Definition: CUError.h:62
CU_EXPORT const char * CU_get_error_msg(void)
Retrieves a message corresponding to the current framework error code.
Definition: CUError.c:86
CU_EXPORT CU_ErrorCode CU_get_error(void)
Retrieves the current CUnit framework error code.
Definition: CUError.c:80
CU_EXPORT void CU_set_error_action(CU_ErrorAction action)
Sets the action to take when a framework error condition occurs.
Definition: CUError.c:92
@ CUEA_ABORT
The application should exit() when an error conditions occurs.
Definition: CUError.h:103
@ CUEA_FAIL
Runs should be stopped when an error condition occurs.
Definition: CUError.h:102
@ CUEA_IGNORE
Runs should be continued when an error condition occurs (if possible).
Definition: CUError.h:101
@ CUE_NOREGISTRY
Test registry not initialized.
Definition: CUError.h:68
@ CUE_NOSUITE
A required CU_pSuite pointer was NULL.
Definition: CUError.h:72
@ CUE_SCLEAN_FAILED
Suite cleanup failed.
Definition: CUError.h:75
@ CUE_SINIT_FAILED
Suite initialization failed.
Definition: CUError.h:74
@ CUE_DUP_TEST
Duplicate test case name not allowed.
Definition: CUError.h:82
@ CUE_NOMEMORY
Memory allocation failed.
Definition: CUError.h:65
@ CUE_DUP_SUITE
Duplicate suite name not allowed.
Definition: CUError.h:76
@ CUE_SUITE_INACTIVE
Test run initiated for an inactive suite.
Definition: CUError.h:77
@ CUE_REGISTRY_EXISTS
Attempt to CU_set_registry() without CU_cleanup_registry().
Definition: CUError.h:69
@ CUE_TEST_INACTIVE
Test run initiated for an inactive test.
Definition: CUError.h:84
@ CUE_FCLOSE_FAILED
An error occurred closing a file.
Definition: CUError.h:88
@ CUE_FOPEN_FAILED
An error occurred opening a file.
Definition: CUError.h:87
@ CUE_NO_TESTNAME
Required CU_Test name not provided.
Definition: CUError.h:81
@ CUE_TEST_NOT_IN_SUITE
Test not registered in specified suite.
Definition: CUError.h:83
@ CUE_NO_SUITENAME
Required CU_Suite name not provided.
Definition: CUError.h:73
@ CUE_BAD_FILENAME
A bad filename was requested (NULL, empty, nonexistent, etc.).
Definition: CUError.h:89
@ CUE_WRITE_ERROR
An error occurred during a write to a file.
Definition: CUError.h:90
@ CUE_NOTEST
A required CU_pTest or CU_TestFunc pointer was NULL.
Definition: CUError.h:80
@ CUE_SUCCESS
No error condition.
Definition: CUError.h:64