src/cx/test.h

Sun, 22 Dec 2024 22:10:04 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 22 Dec 2024 22:10:04 +0100
changeset 1047
40aad3f0bc9e
parent 993
b642eca4b956
permissions
-rw-r--r--

don't trust that size_t always has word width

it should be the case on all platforms supported by UCX, but it's not strictly defined in POSIX that it must be the case

766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 * @file: test.h
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 * UCX Test Framework.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 * Usage of this test framework:
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 * **** IN HEADER FILE: ****
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 * <pre>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 * CX_TEST(function_name);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 * CX_TEST_SUBROUTINE(subroutine_name, paramlist); // optional
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 * </pre>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 * **** IN SOURCE FILE: ****
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 * <pre>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 * CX_TEST_SUBROUTINE(subroutine_name, paramlist) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 * // tests with CX_TEST_ASSERT()
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 * }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 * CX_TEST(function_name) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 * // memory allocation and other stuff here
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
51 * #CX_TEST_DO {
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
52 * // tests with CX_TEST_ASSERT() and/or
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
53 * // calls with CX_TEST_CALL_SUBROUTINE() here
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
54 * }
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 * // cleanup of memory here
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 * }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 * </pre>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 * @attention Do not call own functions within a test, that use
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 * CX_TEST_ASSERT() macros and are not defined by using CX_TEST_SUBROUTINE().
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 * @author Mike Becker
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 * @author Olaf Wintermann
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 #ifndef UCX_TEST_H
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 #define UCX_TEST_H
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69
959
0e1bf3c199bf add common.h include to test.h - fixes #464
Mike Becker <universe@uap-core.de>
parents: 890
diff changeset
70 #include "common.h"
0e1bf3c199bf add common.h include to test.h - fixes #464
Mike Becker <universe@uap-core.de>
parents: 890
diff changeset
71
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 #include <stdio.h>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 #include <string.h>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 #include <setjmp.h>
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 #ifdef __cplusplus
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 extern "C" {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 #endif
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 #ifndef __FUNCTION__
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 * Alias for the <code>__func__</code> preprocessor macro.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 * Some compilers use <code>__func__</code> and others use __FUNCTION__.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 * We use __FUNCTION__ so we define it for those compilers which use
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 * <code>__func__</code>.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 #define __FUNCTION__ __func__
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 #endif
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89
814
5f9e07d3dd6c fix using warning options with compilers which do not support them - fixes #363
Mike Becker <universe@uap-core.de>
parents: 784
diff changeset
90 //
5f9e07d3dd6c fix using warning options with compilers which do not support them - fixes #363
Mike Becker <universe@uap-core.de>
parents: 784
diff changeset
91 #if !defined(__clang__) && __GNUC__ > 3
5f9e07d3dd6c fix using warning options with compilers which do not support them - fixes #363
Mike Becker <universe@uap-core.de>
parents: 784
diff changeset
92 #pragma GCC diagnostic ignored "-Wclobbered"
5f9e07d3dd6c fix using warning options with compilers which do not support them - fixes #363
Mike Becker <universe@uap-core.de>
parents: 784
diff changeset
93 #endif
5f9e07d3dd6c fix using warning options with compilers which do not support them - fixes #363
Mike Becker <universe@uap-core.de>
parents: 784
diff changeset
94
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 /** Type for the CxTestSuite. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 typedef struct CxTestSuite CxTestSuite;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 /** Pointer to a test function. */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
99 cx_attr_nonnull
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 typedef void(*CxTest)(CxTestSuite *, void *, cx_write_func);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 /** Type for the internal list of test cases. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 typedef struct CxTestSet CxTestSet;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 /** Structure for the internal list of test cases. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 struct CxTestSet {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 /** Test case. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 CxTest test;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 /** Pointer to the next list element. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 CxTestSet *next;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 };
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 * A test suite containing multiple test cases.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 struct CxTestSuite {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120 /** The number of successful tests after the suite has been run. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 unsigned int success;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 /** The number of failed tests after the suite has been run. */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 unsigned int failure;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 /** The optional name of this test suite. */
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 814
diff changeset
127 const char *name;
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 * Internal list of test cases.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 * Use cx_test_register() to add tests to this list.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 CxTestSet *tests;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 };
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 * Creates a new test suite.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 * @param name optional name of the suite
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 * @return a new test suite
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
141 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
142 cx_attr_nodiscard
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
143 cx_attr_cstr_arg(1)
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
144 cx_attr_malloc
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 814
diff changeset
145 static inline CxTestSuite* cx_test_suite_new(const char *name) {
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 CxTestSuite* suite = (CxTestSuite*) malloc(sizeof(CxTestSuite));
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 if (suite != NULL) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148 suite->name = name;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 suite->success = 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 suite->failure = 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151 suite->tests = NULL;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 return suite;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 /**
993
b642eca4b956 make names of destroy and free functions consistent - fixes #484
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
158 * Deallocates a test suite.
b642eca4b956 make names of destroy and free functions consistent - fixes #484
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
159 *
b642eca4b956 make names of destroy and free functions consistent - fixes #484
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
160 * @param suite the test suite to free
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
161 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
162 static inline void cx_test_suite_free(CxTestSuite* suite) {
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
163 if (suite == NULL) return;
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 CxTestSet *l = suite->tests;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165 while (l != NULL) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 CxTestSet *e = l;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 l = l->next;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 free(e);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 free(suite);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 * Registers a test function with the specified test suite.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 * @param suite the suite, the test function shall be added to
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 * @param test the test function to register
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 * @return zero on success or non-zero on failure
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
180 cx_attr_nonnull
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181 static inline int cx_test_register(CxTestSuite* suite, CxTest test) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 CxTestSet *t = (CxTestSet*) malloc(sizeof(CxTestSet));
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 if (t) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
184 t->test = test;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
185 t->next = NULL;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
186 if (suite->tests == NULL) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
187 suite->tests = t;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 } else {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 CxTestSet *last = suite->tests;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190 while (last->next) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 last = last->next;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 last->next = t;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
194 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195 return 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
196 } else {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
197 return 1;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
198 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
199 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
200
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
201 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
202 * Runs a test suite and writes the test log to the specified stream.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
203 * @param suite the test suite to run
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
204 * @param out_target the target buffer or file to write the output to
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
205 * @param out_writer the write function writing to \p out_target
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
206 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 959
diff changeset
207 cx_attr_nonnull
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
208 static inline void cx_test_run(CxTestSuite *suite,
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
209 void *out_target, cx_write_func out_writer) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
210 if (suite->name == NULL) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
211 out_writer("*** Test Suite ***\n", 1, 19, out_target);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
212 } else {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
213 out_writer("*** Test Suite : ", 1, 17, out_target);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
214 out_writer(suite->name, 1, strlen(suite->name), out_target);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
215 out_writer(" ***\n", 1, 5, out_target);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
216 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
217 suite->success = 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
218 suite->failure = 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
219 for (CxTestSet *elem = suite->tests; elem; elem = elem->next) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
220 elem->test(suite, out_target, out_writer);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
221 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
222 out_writer("\nAll test completed.\n", 1, 21, out_target);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
223 char total[80];
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
224 int len = snprintf(
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
225 total, 80,
768
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
226 " Total: %u\n Success: %u\n Failure: %u\n\n",
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
227 suite->success + suite->failure, suite->success, suite->failure
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
228 );
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
229 out_writer(total, 1, len, out_target);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
232 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
233 * Runs a test suite and writes the test log to the specified FILE stream.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
234 * @param suite the test suite to run
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
235 * @param file the target file to write the output to
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
236 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 #define cx_test_run_f(suite, file) cx_test_run(suite, (void*)file, (cx_write_func)fwrite)
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
239 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
240 * Runs a test suite and writes the test log to stdout.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
241 * @param suite the test suite to run
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
242 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
243 #define cx_test_run_stdout(suite) cx_test_run_f(suite, stdout)
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
245 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
246 * Macro for a #CxTest function header.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
247 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
248 * Use this macro to declare and/or define a #CxTest function.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
249 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250 * @param name the name of the test function
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
251 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
252 #define CX_TEST(name) void name(CxTestSuite* _suite_,void *_output_, cx_write_func _writefnc_)
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
253
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
254 /**
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
255 * Defines the scope of a test.
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
256 * @attention Any CX_TEST_ASSERT() calls must be performed in scope of
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
257 * #CX_TEST_DO.
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
258 */
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
259 #define CX_TEST_DO _writefnc_("Running ", 1, 8, _output_);\
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
260 _writefnc_(__FUNCTION__, 1, strlen(__FUNCTION__), _output_);\
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
261 _writefnc_("... ", 1, 4, _output_);\
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
262 jmp_buf _env_;\
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
263 for (unsigned int _cx_test_loop_ = 0 ;\
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
264 _cx_test_loop_ == 0 && !setjmp(_env_);\
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
265 _writefnc_("success.\n", 1, 9, _output_),\
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
266 _suite_->success++, _cx_test_loop_++)
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
267
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
268 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
269 * Checks a test assertion.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
270 * If the assertion is correct, the test carries on. If the assertion is not
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
271 * correct, the specified message (terminated by a dot and a line break) is
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
272 * written to the test suites output stream.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
273 * @param condition the condition to check
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
274 * @param message the message that shall be printed out on failure
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
275 */
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
276 #define CX_TEST_ASSERTM(condition,message) if (!(condition)) { \
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 814
diff changeset
277 const char *_assert_msg_ = message; \
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
278 _writefnc_(_assert_msg_, 1, strlen(_assert_msg_), _output_); \
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
279 _writefnc_(".\n", 1, 2, _output_); \
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
280 _suite_->failure++; \
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
281 longjmp(_env_, 1);\
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
282 } (void) 0
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
283
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
284 /**
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
285 * Checks a test assertion.
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
286 * If the assertion is correct, the test carries on. If the assertion is not
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
287 * correct, the specified message (terminated by a dot and a line break) is
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
288 * written to the test suites output stream.
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
289 * @param condition the condition to check
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
290 */
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
291 #define CX_TEST_ASSERT(condition) CX_TEST_ASSERTM(condition, #condition " failed")
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
292
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
293 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
294 * Macro for a test subroutine function header.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
295 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
296 * Use this to declare and/or define a subroutine that can be called by using
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
297 * CX_TEST_CALL_SUBROUTINE().
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
298 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
299 * @param name the name of the subroutine
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
300 * @param ... the parameter list
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
301 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
302 * @see CX_TEST_CALL_SUBROUTINE()
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
303 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
304 #define CX_TEST_SUBROUTINE(name,...) void name(CxTestSuite* _suite_,\
784
ba5faf85dec6 fix broken CX_TEST_SUBROUTINE - relates to #341
Mike Becker <universe@uap-core.de>
parents: 768
diff changeset
305 void *_output_, cx_write_func _writefnc_, jmp_buf _env_, __VA_ARGS__)
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
306
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
307 /**
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
308 * Macro for calling a test subroutine.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
309 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
310 * Subroutines declared with CX_TEST_SUBROUTINE() can be called by using this
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
311 * macro.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
312 *
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
313 * @remark You may <b>only</b> call subroutines within a #CX_TEST_DO block.
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
314 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
315 * @param name the name of the subroutine
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
316 * @param ... the argument list
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
317 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
318 * @see CX_TEST_SUBROUTINE()
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
319 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
320 #define CX_TEST_CALL_SUBROUTINE(name,...) \
784
ba5faf85dec6 fix broken CX_TEST_SUBROUTINE - relates to #341
Mike Becker <universe@uap-core.de>
parents: 768
diff changeset
321 name(_suite_,_output_,_writefnc_,_env_,__VA_ARGS__)
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
322
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
323 #ifdef __cplusplus
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
324 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
325 #endif
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
326
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
327 #endif /* UCX_TEST_H */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328

mercurial