ucx/test.h

Sat, 15 Jul 2017 22:36:29 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 15 Jul 2017 22:36:29 +0200
changeset 245
db732f8c083a
parent 225
a1a068c2c4ef
child 250
b7d1317b138e
permissions
-rw-r--r--

adds AVL predecessor and successor functions

103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
1 /*
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
3 *
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
4 * Copyright 2016 Olaf Wintermann. All rights reserved.
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
5 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
6 * Redistribution and use in source and binary forms, with or without
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
7 * modification, are permitted provided that the following conditions are met:
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
8 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
10 * notice, this list of conditions and the following disclaimer.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
11 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
14 * documentation and/or other materials provided with the distribution.
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
27 */
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
28
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
29 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
30 * @file: test.h
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
31 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
32 * UCX Test Framework.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
33 *
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
34 * Usage of this test framework:
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
35 *
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
36 * **** IN HEADER FILE: ****
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
37 *
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
38 * <pre>
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
39 * UCX_TEST(function_name)
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
40 * UCX_TEST_SUBROUTINE(subroutine_name, paramlist) // optional
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
41 * </pre>
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
42 *
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
43 * **** IN SOURCE FILE: ****
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
44 * <pre>
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
45 * UCX_TEST_SUBROUTINE(subroutine_name, paramlist) {
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
46 * // tests with UCX_TEST_ASSERT()
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
47 * }
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
48 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
49 * UCX_TEST(function_name) {
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
50 * // memory allocation and other stuff here
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
51 * #UCX_TEST_BEGIN
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
52 * // tests with UCX_TEST_ASSERT() and/or
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
53 * // calls with UCX_TEST_CALL_SUBROUTINE() here
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
54 * #UCX_TEST_END
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
55 * // cleanup of memory here
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
56 * }
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
57 * </pre>
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
58 *
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
59 * <b>Note:</b> if a test fails, a longjump is performed
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
60 * back to the #UCX_TEST_BEGIN macro!
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
61 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
62 * <b>Attention:</b> Do not call own functions within a test, that use
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
63 * UCX_TEST_ASSERT() macros and are not defined by using UCX_TEST_SUBROUTINE().
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
64 *
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
65 *
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
66 * @author Mike Becker
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
67 * @author Olaf Wintermann
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
68 *
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 */
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70
120
8170f658f017 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
71 #ifndef UCX_TEST_H
8170f658f017 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
72 #define UCX_TEST_H
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
74 #include "ucx.h"
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 #include <stdio.h>
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 #include <string.h>
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
77 #include <setjmp.h>
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 #ifdef __cplusplus
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 extern "C" {
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 #endif
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
83 #ifndef __FUNCTION__
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
84
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
85 /**
135
a0aa1c15f46b documented mempool + some fixes
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
86 * Alias for the <code>__func__</code> preprocessor macro.
178
8c89e454000f fixed doc for __FUNCTION__ macro
Mike Becker <universe@uap-core.de>
parents: 177
diff changeset
87 * Some compilers use <code>__func__</code> and others use __FUNCTION__.
8c89e454000f fixed doc for __FUNCTION__ macro
Mike Becker <universe@uap-core.de>
parents: 177
diff changeset
88 * We use __FUNCTION__ so we define it for those compilers which use
135
a0aa1c15f46b documented mempool + some fixes
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
89 * <code>__func__</code>.
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
90 */
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
91 #define __FUNCTION__ __func__
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
92 #endif
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
93
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
94 /** Type for the UcxTestSuite. */
83
3b552d7a9610 modified code to compile with -pedantic
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
95 typedef struct UcxTestSuite UcxTestSuite;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
96
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
97 /** Pointer to a test function. */
83
3b552d7a9610 modified code to compile with -pedantic
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
98 typedef void(*UcxTest)(UcxTestSuite*,FILE*);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
99
138
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
100 /** Type for the internal list of test cases. */
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
101 typedef struct UcxTestList UcxTestList;
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
102
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
103 /** Structure for the internal list of test cases. */
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
104 struct UcxTestList {
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
105
138
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
106 /** Test case. */
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
107 UcxTest test;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
108
138
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
109 /** Pointer to the next list element. */
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
110 UcxTestList *next;
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
111 };
83
3b552d7a9610 modified code to compile with -pedantic
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
112
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
113 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
114 * A test suite containing multiple test cases.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
115 */
83
3b552d7a9610 modified code to compile with -pedantic
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
116 struct UcxTestSuite {
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
117
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
118 /** The number of successful tests after the suite has been run. */
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 unsigned int success;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
120
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
121 /** The number of failed tests after the suite has been run. */
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 unsigned int failure;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
123
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
124 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
125 * Internal list of test cases.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
126 * Use ucx_test_register() to add tests to this list.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
127 */
83
3b552d7a9610 modified code to compile with -pedantic
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
128 UcxTestList *tests;
3b552d7a9610 modified code to compile with -pedantic
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
129 };
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
131 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
132 * Creates a new test suite.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
133 * @return a new test suite
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
134 */
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135 UcxTestSuite* ucx_test_suite_new();
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
136
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
137 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
138 * Destroys a test suite.
138
7800811078b8 documented map.h + changed return value of ucx_map_iter_next()
Mike Becker <universe@uap-core.de>
parents: 135
diff changeset
139 * @param suite the test suite to destroy
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
140 */
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
141 void ucx_test_suite_free(UcxTestSuite* suite);
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
143 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
144 * Registers a test function with the specified test suite.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
145 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
146 * @param suite the suite, the test function shall be added to
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
147 * @param test the test function to register
135
a0aa1c15f46b documented mempool + some fixes
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
148 * @return <code>EXIT_SUCCESS</code> on success or
a0aa1c15f46b documented mempool + some fixes
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
149 * <code>EXIT_FAILURE</code> on failure
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
150 */
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
151 int ucx_test_register(UcxTestSuite* suite, UcxTest test);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
152
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
153 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
154 * Runs a test suite and writes the test log to the specified stream.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
155 * @param suite the test suite to run
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
156 * @param outstream the stream the log shall be written to
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
157 */
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
158 void ucx_test_run(UcxTestSuite* suite, FILE* outstream);
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
160 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
161 * Macro for a #UcxTest function header.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
162 *
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
163 * Use this macro to declare and/or define a #UcxTest function.
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
164 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
165 * @param name the name of the test function
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
166 */
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
167 #define UCX_TEST(name) void name(UcxTestSuite* _suite_,FILE *_output_)
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
168
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
169 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
170 * Marks the begin of a test.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
171 * <b>Note:</b> Any UCX_TEST_ASSERT() calls must be performed <b>after</b>
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
172 * #UCX_TEST_BEGIN.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
173 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
174 * @see #UCX_TEST_END
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
175 */
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
176 #define UCX_TEST_BEGIN fwrite("Running ", 1, 8, _output_);\
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
177 fwrite(__FUNCTION__, 1, strlen(__FUNCTION__), _output_);\
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
178 fwrite("... ", 1, 4, _output_);\
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
179 jmp_buf _env_; \
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
180 if (!setjmp(_env_)) {
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
182 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
183 * Checks a test assertion.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
184 * If the assertion is correct, the test carries on. If the assertion is not
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
185 * correct, the specified message (terminated by a dot and a line break) is
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
186 * written to the test suites output stream.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
187 * @param condition the condition to check
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
188 * @param message the message that shall be printed out on failure
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
189 */
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190 #define UCX_TEST_ASSERT(condition,message) if (!(condition)) { \
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 fwrite(message".\n", 1, 2+strlen(message), _output_); \
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 _suite_->failure++; \
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
193 longjmp(_env_, 1);\
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
194 }
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
196 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
197 * Macro for a test subroutine function header.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
198 *
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
199 * Use this to declare and/or define a subroutine that can be called by using
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
200 * UCX_TEST_CALL_SUBROUTINE().
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
201 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
202 * @param name the name of the subroutine
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
203 * @param ... the parameter list
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
204 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
205 * @see UCX_TEST_CALL_SUBROUTINE()
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
206 */
88
18823857ce79 variadic test subroutines
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
207 #define UCX_TEST_SUBROUTINE(name,...) void name(UcxTestSuite* _suite_,\
18823857ce79 variadic test subroutines
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
208 FILE *_output_, jmp_buf _env_, __VA_ARGS__)
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
209
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
210 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
211 * Macro for calling a test subroutine.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
212 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
213 * Subroutines declared with UCX_TEST_SUBROUTINE() can be called by using this
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
214 * macro.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
215 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
216 * <b>Note:</b> You may <b>only</b> call subroutines within a #UCX_TEST_BEGIN-
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
217 * #UCX_TEST_END-block.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
218 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
219 * @param name the name of the subroutine
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
220 * @param ... the argument list
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
221 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
222 * @see UCX_TEST_SUBROUTINE()
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
223 */
88
18823857ce79 variadic test subroutines
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
224 #define UCX_TEST_CALL_SUBROUTINE(name,...) \
18823857ce79 variadic test subroutines
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
225 name(_suite_,_output_,_env_,__VA_ARGS__);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
226
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
227 /**
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
228 * Marks the end of a test.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
229 * <b>Note:</b> Any UCX_TEST_ASSERT() calls must be performed <b>before</b>
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
230 * #UCX_TEST_END.
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
231 *
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
232 * @see #UCX_TEST_BEGIN
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
233 */
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
234 #define UCX_TEST_END fwrite("success.\n", 1, 9, _output_); _suite_->success++;}
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
235
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
236 #ifdef __cplusplus
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 }
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238 #endif
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
239
120
8170f658f017 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
240 #endif /* UCX_TEST_H */
26
59f147baea31 added test framework and foreach macro
Mike Becker <universe@uap-core.de>
parents:
diff changeset
241

mercurial