Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
abts.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #ifdef WIN32
26 #include <io.h>
27 #else
28 #include <unistd.h>
29 #endif
30 
31 #ifndef ABTS_H
32 #define ABTS_H
33 
34 #ifndef FALSE
35 #define FALSE 0
36 #endif
37 #ifndef TRUE
38 #define TRUE 1
39 #endif
40 
41 struct sub_suite {
42  const char *name;
43  int num_test;
44  int failed;
45  int skipped;
46  int not_run;
47  int not_impl;
48  struct sub_suite *next;
49 };
50 typedef struct sub_suite sub_suite;
51 
52 struct abts_suite {
55 };
56 typedef struct abts_suite abts_suite;
57 
58 struct abts_case {
59  int failed;
60  int skipped;
62 };
63 typedef struct abts_case abts_case;
64 
65 typedef void (*test_func)(abts_case *tc, void *data);
66 
67 #define ADD_SUITE(suite) abts_add_suite(suite, __FILE__);
68 
69 abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name);
70 void abts_run_test(abts_suite *ts, test_func f, void *value);
71 void abts_log_message(const char *fmt, ...);
72 
73 void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno);
74 void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno);
75 void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno);
76 void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
77  size_t n, int lineno);
78 void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno);
79 void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
80 void abts_true(abts_case *tc, int condition, int lineno);
81 void abts_fail(abts_case *tc, const char *message, int lineno);
82 void abts_skip(abts_case *tc, const char *message, int lineno);
83 void abts_not_impl(abts_case *tc, const char *message, int lineno);
84 void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
85 void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno);
86 
87 /* Convenience macros. Ryan hates these! */
88 #define ABTS_INT_EQUAL(a, b, c) abts_int_equal(a, b, c, __LINE__)
89 #define ABTS_INT_NEQUAL(a, b, c) abts_int_nequal(a, b, c, __LINE__)
90 #define ABTS_STR_EQUAL(a, b, c) abts_str_equal(a, b, c, __LINE__)
91 #define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__)
92 #define ABTS_PTR_NOTNULL(a, b) abts_ptr_notnull(a, b, __LINE__)
93 #define ABTS_PTR_EQUAL(a, b, c) abts_ptr_equal(a, b, c, __LINE__)
94 #define ABTS_TRUE(a, b) abts_true(a, b, __LINE__);
95 #define ABTS_FAIL(a, b) abts_fail(a, b, __LINE__);
96 #define ABTS_NOT_IMPL(a, b) abts_not_impl(a, b, __LINE__);
97 #define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__);
98 
99 #define ABTS_SIZE_EQUAL(a, b, c) abts_size_equal(a, b, c, __LINE__)
100 
101 /* When skipping tests, make a reference to the test data parameter
102  to avoid unused variable warnings. */
103 #define ABTS_SKIP(tc, data, msg) do { \
104  ((void)(data)); \
105  abts_skip((tc), (msg), __LINE__); \
106  } while (0)
107 
110 
111 
112 #endif
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
int not_run
Definition: abts.h:46
void abts_skip(abts_case *tc, const char *message, int lineno)
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno)
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual, size_t n, int lineno)
void abts_true(abts_case *tc, int condition, int lineno)
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno)
void(* test_func)(abts_case *tc, void *data)
Definition: abts.h:65
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno)
int skipped
Definition: abts.h:45
int num_test
Definition: abts.h:43
sub_suite * suite
Definition: abts.h:61
void abts_not_impl(abts_case *tc, const char *message, int lineno)
void abts_assert(abts_case *tc, const char *message, int condition, int lineno)
abts_suite * run_tests1(abts_suite *suite)
Definition: abts.h:52
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno)
abts_suite * abts_add_suite(abts_suite *suite, const char *suite_name)
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno)
int failed
Definition: abts.h:59
abts_suite * run_tests(abts_suite *suite)
Definition: abts.h:58
int failed
Definition: abts.h:44
int not_impl
Definition: abts.h:47
void abts_fail(abts_case *tc, const char *message, int lineno)
sub_suite * head
Definition: abts.h:53
sub_suite * tail
Definition: abts.h:54
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno)
int skipped
Definition: abts.h:60
const char * name
Definition: abts.h:42
typedef void(APR_THREAD_FUNC *PFN_HSE_IO_COMPLETION)(EXTENSION_CONTROL_BLOCK *ecb
struct sub_suite * next
Definition: abts.h:48
Definition: abts.h:41
void abts_run_test(abts_suite *ts, test_func f, void *value)
void abts_log_message(const char *fmt,...)