1251876Speter/* Licensed to the Apache Software Foundation (ASF) under one or more
2251876Speter * contributor license agreements.  See the NOTICE file distributed with
3251876Speter * this work for additional information regarding copyright ownership.
4251876Speter * The ASF licenses this file to You under the Apache License, Version 2.0
5251876Speter * (the "License"); you may not use this file except in compliance with
6251876Speter * the License.  You may obtain a copy of the License at
7251876Speter *
8251876Speter *     http://www.apache.org/licenses/LICENSE-2.0
9251876Speter *
10251876Speter * Unless required by applicable law or agreed to in writing, software
11251876Speter * distributed under the License is distributed on an "AS IS" BASIS,
12251876Speter * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13251876Speter * See the License for the specific language governing permissions and
14251876Speter * limitations under the License.
15251876Speter */
16251876Speter
17251876Speter#ifdef __cplusplus
18251876Speterextern "C" {
19251876Speter#endif
20251876Speter
21251876Speter#include <stdarg.h>
22251876Speter#include <stdio.h>
23251876Speter#include <stdlib.h>
24251876Speter#include <string.h>
25251876Speter
26251876Speter#ifdef WIN32
27251876Speter#include <io.h>
28251876Speter#else
29251876Speter#include <unistd.h>
30251876Speter#endif
31251876Speter
32251876Speter#ifndef ABTS_H
33251876Speter#define ABTS_H
34251876Speter
35251876Speter#ifndef FALSE
36251876Speter#define FALSE 0
37251876Speter#endif
38251876Speter#ifndef TRUE
39251876Speter#define TRUE  1
40251876Speter#endif
41251876Speter
42251876Speterstruct sub_suite {
43251876Speter    const char *name;
44251876Speter    int num_test;
45251876Speter    int failed;
46251876Speter    int not_run;
47251876Speter    int not_impl;
48251876Speter    struct sub_suite *next;
49251876Speter};
50251876Spetertypedef struct sub_suite sub_suite;
51251876Speter
52251876Speterstruct abts_suite {
53251876Speter    sub_suite *head;
54251876Speter    sub_suite *tail;
55251876Speter};
56251876Spetertypedef struct abts_suite abts_suite;
57251876Speter
58251876Speterstruct abts_case {
59251876Speter    int failed;
60251876Speter    sub_suite *suite;
61251876Speter};
62251876Spetertypedef struct abts_case abts_case;
63251876Speter
64251876Spetertypedef void (*test_func)(abts_case *tc, void *data);
65251876Speter
66251876Speter#define ADD_SUITE(suite) abts_add_suite(suite, __FILE__);
67251876Speter
68251876Speterabts_suite *abts_add_suite(abts_suite *suite, const char *suite_name);
69251876Spetervoid abts_run_test(abts_suite *ts, test_func f, void *value);
70251876Spetervoid abts_log_message(const char *fmt, ...);
71251876Speter
72251876Spetervoid abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno);
73251876Spetervoid abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno);
74251876Spetervoid abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno);
75251876Spetervoid abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
76251876Speter                       size_t n, int lineno);
77251876Spetervoid abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno);
78251876Spetervoid abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
79251876Spetervoid abts_true(abts_case *tc, int condition, int lineno);
80251876Spetervoid abts_fail(abts_case *tc, const char *message, int lineno);
81251876Spetervoid abts_not_impl(abts_case *tc, const char *message, int lineno);
82251876Spetervoid abts_assert(abts_case *tc, const char *message, int condition, int lineno);
83251876Speter
84251876Speter/* Convenience macros. Ryan hates these! */
85251876Speter#define ABTS_INT_EQUAL(a, b, c)     abts_int_equal(a, b, c, __LINE__)
86251876Speter#define ABTS_INT_NEQUAL(a, b, c)    abts_int_nequal(a, b, c, __LINE__)
87251876Speter#define ABTS_STR_EQUAL(a, b, c)     abts_str_equal(a, b, c, __LINE__)
88251876Speter#define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__)
89251876Speter#define ABTS_PTR_NOTNULL(a, b)      abts_ptr_notnull(a, b, __LINE__)
90251876Speter#define ABTS_PTR_EQUAL(a, b, c)     abts_ptr_equal(a, b, c, __LINE__)
91251876Speter#define ABTS_TRUE(a, b)             abts_true(a, b, __LINE__);
92251876Speter#define ABTS_FAIL(a, b)             abts_fail(a, b, __LINE__);
93251876Speter#define ABTS_NOT_IMPL(a, b)         abts_not_impl(a, b, __LINE__);
94251876Speter#define ABTS_ASSERT(a, b, c)        abts_assert(a, b, c, __LINE__);
95251876Speter
96251876Speter#endif
97251876Speter
98251876Speter#ifdef __cplusplus
99251876Speter}
100251876Speter#endif
101251876Speter
102