00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020 #include <stdarg.h>
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024
00025 #ifdef WIN32
00026 #include <io.h>
00027 #else
00028 #include <unistd.h>
00029 #endif
00030
00031 #ifndef ABTS_H
00032 #define ABTS_H
00033
00034 #ifndef FALSE
00035 #define FALSE 0
00036 #endif
00037 #ifndef TRUE
00038 #define TRUE 1
00039 #endif
00040
00041 struct sub_suite {
00042 const char *name;
00043 int num_test;
00044 int failed;
00045 int not_run;
00046 int not_impl;
00047 struct sub_suite *next;
00048 };
00049 typedef struct sub_suite sub_suite;
00050
00051 struct abts_suite {
00052 sub_suite *head;
00053 sub_suite *tail;
00054 };
00055 typedef struct abts_suite abts_suite;
00056
00057 struct abts_case {
00058 int failed;
00059 sub_suite *suite;
00060 };
00061 typedef struct abts_case abts_case;
00062
00063 typedef void (*test_func)(abts_case *tc, void *data);
00064
00065 #define ADD_SUITE(suite) abts_add_suite(suite, __FILE__);
00066
00067 abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name);
00068 void abts_run_test(abts_suite *ts, test_func f, void *value);
00069 void abts_log_message(const char *fmt, ...);
00070
00071 void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno);
00072 void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno);
00073 void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno);
00074 void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
00075 size_t n, int lineno);
00076 void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno);
00077 void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
00078 void abts_true(abts_case *tc, int condition, int lineno);
00079 void abts_fail(abts_case *tc, const char *message, int lineno);
00080 void abts_not_impl(abts_case *tc, const char *message, int lineno);
00081 void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
00082
00083
00084 #define ABTS_INT_EQUAL(a, b, c) abts_int_equal(a, b, c, __LINE__)
00085 #define ABTS_INT_NEQUAL(a, b, c) abts_int_nequal(a, b, c, __LINE__)
00086 #define ABTS_STR_EQUAL(a, b, c) abts_str_equal(a, b, c, __LINE__)
00087 #define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__)
00088 #define ABTS_PTR_NOTNULL(a, b) abts_ptr_notnull(a, b, __LINE__)
00089 #define ABTS_PTR_EQUAL(a, b, c) abts_ptr_equal(a, b, c, __LINE__)
00090 #define ABTS_TRUE(a, b) abts_true(a, b, __LINE__);
00091 #define ABTS_FAIL(a, b) abts_fail(a, b, __LINE__);
00092 #define ABTS_NOT_IMPL(a, b) abts_not_impl(a, b, __LINE__);
00093 #define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__);
00094
00095 abts_suite *run_tests(abts_suite *suite);
00096 abts_suite *run_tests1(abts_suite *suite);
00097
00098
00099 #endif
00100
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104