code documentation cleaned
[strongswan.git] / Source / charon / utils / tester.h
1 /**
2 * @file tester.h
3 *
4 * @brief Interface of tester_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef TESTER_H_
24 #define TESTER_H_
25
26 #include <stdio.h>
27
28 #include <types.h>
29
30
31 typedef struct test_t test_t;
32
33 typedef struct tester_t tester_t;
34
35 /**
36 * @brief Representing a specified test.
37 *
38 * @ingroup utils
39 */
40 struct test_t {
41 /**
42 * Testfunction called for this test.
43 *
44 * @param tester associated tester_t object
45 */
46 void (*test_function) (tester_t * tester);
47 /**
48 * Name of the test.
49 */
50 char * test_name;
51 };
52
53 /**
54 * A tester class to perform tests.
55 *
56 * @ingroup utils
57 */
58 struct tester_t {
59
60 /**
61 * @brief Tests all testcases in array tests with specific tester_t object.
62 *
63 * @param tester tester_t object
64 * @param tests pointer to an array of test_t-pointers.
65 * The last item has to be NULL.
66 * @return SUCCESS in any case
67 */
68 status_t (*perform_tests) (tester_t *tester,test_t **tests);
69
70 /**
71 * @brief Run a specific test case.
72 *
73 * @param this tester_t object
74 * @param test pointer to a test_t object which will be performed
75 * @return SUCCESS in any case
76 */
77 status_t (*perform_test) (tester_t *tester, test_t *test);
78
79 /**
80 * Is called in a testcase to check a specific situation for TRUE.
81 *
82 * Log-Values to the tester output are protected from multiple access.
83 *
84 * @warning This function should only be called in a test_function.
85 *
86 * @param this tester_t object
87 * @param to_be_true assert which has to be TRUE
88 * @param assert_name name of the assertion
89 */
90 void (*assert_true) (tester_t *tester, bool to_be_true, char *assert_name);
91
92 /**
93 * Is called in a testcase to check a specific situation for FALSE.
94 *
95 * Log-Values to the tester output are protected from multiple access.
96 *
97 * @warning This function should only be called in a test_function.
98 *
99 * @param this tester_t object
100 * @param to_be_false assert which has to be FALSE
101 * @param assert_name name of the assertion
102 */
103 void (*assert_false) (tester_t *tester, bool to_be_false, char *assert_name);
104
105 /**
106 * @brief Destroys a tester_t object
107 *
108 * @param tester tester_t object
109 * @return SUCCESS in any case
110 */
111 status_t (*destroy) (tester_t *tester);
112 };
113
114 /**
115 * @brief Creates a tester_t object used to perform tests with.
116 *
117 * @param output test output is written to this output.
118 * @param display_succeeded_asserts has to be TRUE, if all asserts should be displayed,
119 * FALSE otherwise
120 *
121 * @return
122 * - tester_t object
123 * - NULL if out of ressources
124 *
125 * @ingroup utils
126 */
127 tester_t *tester_create(FILE *output, bool display_succeeded_asserts);
128
129 #endif /*TESTER_H_*/