79 #ifdef __cplusplus |
79 #ifdef __cplusplus |
80 extern "C" { |
80 extern "C" { |
81 #endif |
81 #endif |
82 |
82 |
83 #ifndef __FUNCTION__ |
83 #ifndef __FUNCTION__ |
|
84 |
84 /** |
85 /** |
85 * Alias for the <code>__func__</code> preprocessor macro. |
86 * Alias for the <code>__func__</code> preprocessor macro. |
86 * Some compilers use <code>__func__</code> and others use __FUNC__. |
87 * Some compilers use <code>__func__</code> and others use __FUNC__. |
87 * We use __FUNC__ so we define it for those compilers which use |
88 * We use __FUNC__ so we define it for those compilers which use |
88 * <code>__func__</code>. |
89 * <code>__func__</code>. |
89 */ |
90 */ |
90 #define __FUNCTION__ __func__ |
91 #define __FUNCTION__ __func__ |
91 #endif |
92 #endif |
92 |
93 |
|
94 /** Type for the UcxTestSuite. */ |
|
95 typedef struct UcxTestSuite UcxTestSuite; |
|
96 |
|
97 /** Pointer to a test function. */ |
|
98 typedef void(*UcxTest)(UcxTestSuite*,FILE*); |
|
99 |
93 /** Type for the internal list of test cases. */ |
100 /** Type for the internal list of test cases. */ |
94 typedef struct UcxTestList UcxTestList; |
101 typedef struct UcxTestList UcxTestList; |
95 /** Type for the UcxTestSuite. */ |
102 |
96 typedef struct UcxTestSuite UcxTestSuite; |
103 /** Structure for the internal list of test cases. */ |
97 /** Pointer to a test function. */ |
104 struct UcxTestList { |
98 typedef void(*UcxTest)(UcxTestSuite*,FILE*); |
105 |
|
106 /** Test case. */ |
|
107 UcxTest test; |
|
108 |
|
109 /** Pointer to the next list element. */ |
|
110 UcxTestList *next; |
|
111 }; |
99 |
112 |
100 /** |
113 /** |
101 * A test suite containing multiple test cases. |
114 * A test suite containing multiple test cases. |
102 */ |
115 */ |
103 struct UcxTestSuite { |
116 struct UcxTestSuite { |
|
117 |
104 /** The number of successful tests after the suite has been run. */ |
118 /** The number of successful tests after the suite has been run. */ |
105 unsigned int success; |
119 unsigned int success; |
|
120 |
106 /** The number of failed tests after the suite has been run. */ |
121 /** The number of failed tests after the suite has been run. */ |
107 unsigned int failure; |
122 unsigned int failure; |
|
123 |
108 /** |
124 /** |
109 * Internal list of test cases. |
125 * Internal list of test cases. |
110 * Use ucx_test_register() to add tests to this list. |
126 * Use ucx_test_register() to add tests to this list. |
111 */ |
127 */ |
112 UcxTestList *tests; |
128 UcxTestList *tests; |
115 /** |
131 /** |
116 * Creates a new test suite. |
132 * Creates a new test suite. |
117 * @return a new test suite |
133 * @return a new test suite |
118 */ |
134 */ |
119 UcxTestSuite* ucx_test_suite_new(); |
135 UcxTestSuite* ucx_test_suite_new(); |
|
136 |
120 /** |
137 /** |
121 * Destroys a test suite. |
138 * Destroys a test suite. |
122 * @param the test suite to destroy |
139 * @param suite the test suite to destroy |
123 */ |
140 */ |
124 void ucx_test_suite_free(UcxTestSuite* suite); |
141 void ucx_test_suite_free(UcxTestSuite* suite); |
125 |
142 |
126 /** |
143 /** |
127 * Registers a test function with the specified test suite. |
144 * Registers a test function with the specified test suite. |
130 * @param test the test function to register |
147 * @param test the test function to register |
131 * @return <code>EXIT_SUCCESS</code> on success or |
148 * @return <code>EXIT_SUCCESS</code> on success or |
132 * <code>EXIT_FAILURE</code> on failure |
149 * <code>EXIT_FAILURE</code> on failure |
133 */ |
150 */ |
134 int ucx_test_register(UcxTestSuite* suite, UcxTest test); |
151 int ucx_test_register(UcxTestSuite* suite, UcxTest test); |
|
152 |
135 /** |
153 /** |
136 * Runs a test suite and writes the test log to the specified stream. |
154 * Runs a test suite and writes the test log to the specified stream. |
137 * @param suite the test suite to run |
155 * @param suite the test suite to run |
138 * @param outstream the stream the log shall be written to |
156 * @param outstream the stream the log shall be written to |
139 */ |
157 */ |