00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: apt_test_suite.h 1708 2010-05-24 17:03:25Z achaloyan $ 00017 */ 00018 00019 #ifndef APT_TEST_SUITE_H 00020 #define APT_TEST_SUITE_H 00021 00022 /** 00023 * @file apt_test_suite.h 00024 * @brief Test Suite and Framework Definitions 00025 */ 00026 00027 #include "apt_string.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 00032 /** Opaque test suite declaration */ 00033 typedef struct apt_test_suite_t apt_test_suite_t; 00034 00035 /** Prototype of test function */ 00036 typedef apt_bool_t (*apt_test_f)(apt_test_suite_t *suite, int argc, const char * const *argv); 00037 00038 /** Test suite as a base for all kind of tests */ 00039 struct apt_test_suite_t { 00040 /** Memory pool to allocate memory from */ 00041 apr_pool_t *pool; 00042 /** Unique name of the test suite */ 00043 apt_str_t name; 00044 /** External object associated with the test suite */ 00045 void *obj; 00046 /** Test function to execute */ 00047 apt_test_f tester; 00048 }; 00049 00050 /** 00051 * Create test suite. 00052 * @param pool the pool to allocate memory from 00053 * @param name the unique name of the test suite 00054 * @param obj the external object associated with the test suite 00055 * @param tester the test function to execute 00056 */ 00057 APT_DECLARE(apt_test_suite_t*) apt_test_suite_create(apr_pool_t *pool, const char *name, 00058 void *obj, apt_test_f tester); 00059 00060 00061 00062 00063 00064 /** Opaque test framework declaration */ 00065 typedef struct apt_test_framework_t apt_test_framework_t; 00066 00067 /** 00068 * Create test framework. 00069 */ 00070 APT_DECLARE(apt_test_framework_t*) apt_test_framework_create(void); 00071 00072 /** 00073 * Destroy test framework. 00074 * @param framework the test framework to destroy 00075 */ 00076 APT_DECLARE(void) apt_test_framework_destroy(apt_test_framework_t *framework); 00077 00078 /** 00079 * Add test suite to framework. 00080 * @param framework the test framework to add test suite to 00081 * @param suite the test suite to add 00082 */ 00083 APT_DECLARE(apt_bool_t) apt_test_framework_suite_add(apt_test_framework_t *framework, apt_test_suite_t *suite); 00084 00085 /** 00086 * Run test suites. 00087 * @param framework the test framework 00088 * @param argc the number of arguments 00089 * @param argv the array of arguments 00090 */ 00091 APT_DECLARE(apt_bool_t) apt_test_framework_run(apt_test_framework_t *framework, int argc, const char * const *argv); 00092 00093 /** 00094 * Retrieve the memory pool. 00095 * @param framework the test framework to retrieve memory pool from 00096 */ 00097 APT_DECLARE(apr_pool_t*) apt_test_framework_pool_get(const apt_test_framework_t *framework); 00098 00099 APT_END_EXTERN_C 00100 00101 #endif /* APT_TEST_SUITE_H */