diff -r 92e482410453 -r d345541018fa docs/api-2.1/test_8h_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/api-2.1/test_8h_source.html Sat Feb 06 19:11:44 2021 +0100 @@ -0,0 +1,93 @@ + + + + + + + +ucx: /home/mike/workspace/c/ucx/src/ucx/test.h Source File + + + + + + + + + +
+
+ + + + + + + +
+
ucx +
+
UAP Common Extensions
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
test.h
+
+
+Go to the documentation of this file.
1 /*
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3  *
4  * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
71 #ifndef UCX_TEST_H
72 #define UCX_TEST_H
73 
74 #include "ucx.h"
75 #include <stdio.h>
76 #include <string.h>
77 #include <setjmp.h>
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 #ifndef __FUNCTION__
84 
91 #define __FUNCTION__ __func__
92 #endif
93 
95 typedef struct UcxTestSuite UcxTestSuite;
96 
98 typedef void(*UcxTest)(UcxTestSuite*,FILE*);
99 
101 typedef struct UcxTestList UcxTestList;
102 
104 struct UcxTestList {
105 
108 
111 };
112 
116 struct UcxTestSuite {
117 
119  unsigned int success;
120 
122  unsigned int failure;
123 
129 };
130 
135 UcxTestSuite* ucx_test_suite_new();
136 
141 void ucx_test_suite_free(UcxTestSuite* suite);
142 
151 int ucx_test_register(UcxTestSuite* suite, UcxTest test);
152 
158 void ucx_test_run(UcxTestSuite* suite, FILE* outstream);
159 
167 #define UCX_TEST(name) void name(UcxTestSuite* _suite_,FILE *_output_)
168 
176 #define UCX_TEST_BEGIN fwrite("Running ", 1, 8, _output_);\
177  fwrite(__FUNCTION__, 1, strlen(__FUNCTION__), _output_);\
178  fwrite("... ", 1, 4, _output_);\
179  jmp_buf _env_; \
180  if (!setjmp(_env_)) {
181 
190 #define UCX_TEST_ASSERT(condition,message) if (!(condition)) { \
191  fwrite(message".\n", 1, 2+strlen(message), _output_); \
192  _suite_->failure++; \
193  longjmp(_env_, 1);\
194  }
195 
207 #define UCX_TEST_SUBROUTINE(name,...) void name(UcxTestSuite* _suite_,\
208  FILE *_output_, jmp_buf _env_, __VA_ARGS__)
209 
224 #define UCX_TEST_CALL_SUBROUTINE(name,...) \
225  name(_suite_,_output_,_env_,__VA_ARGS__);
226 
234 #define UCX_TEST_END fwrite("success.\n", 1, 9, _output_); _suite_->success++;}
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* UCX_TEST_H */
241 
unsigned int success
The number of successful tests after the suite has been run.
Definition: test.h:119
+
Bounded string implementation.
+
Main UCX Header providing most common definitions.
+
UcxTest test
Test case.
Definition: test.h:107
+
int ucx_test_register(UcxTestSuite *suite, UcxTest test)
Registers a test function with the specified test suite.
Definition: test.c:52
+
void ucx_test_run(UcxTestSuite *suite, FILE *outstream)
Runs a test suite and writes the test log to the specified stream.
Definition: test.c:82
+
Structure for the internal list of test cases.
Definition: test.h:104
+
UcxTestSuite * ucx_test_suite_new()
Creates a new test suite.
Definition: test.c:31
+
UcxTestList * tests
Internal list of test cases.
Definition: test.h:128
+
void(* UcxTest)(UcxTestSuite *, FILE *)
Pointer to a test function.
Definition: test.h:98
+
void ucx_test_suite_free(UcxTestSuite *suite)
Destroys a test suite.
Definition: test.c:42
+
unsigned int failure
The number of failed tests after the suite has been run.
Definition: test.h:122
+
UcxTestList * next
Pointer to the next list element.
Definition: test.h:110
+
A test suite containing multiple test cases.
Definition: test.h:116
+
+ + + +