QOF: test-stuff.h Source File

QOF 0.7.5

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

test-stuff.h
1 /* Modified by bstanley 20010320
2 * Added do_test macro, do_test_call and do_test_call_args,
3 * print_test_results, set_success_print.
4 *
5 * Modified by bstanley 20010323
6 * removed testing functionality which depends on the rest of gnucash -
7 * sepearated into gnc-test-stuff.h
8 *
9 */
10
11 /* Outline of a test program using the new testing functions:
12 #include "test-stuff.h"
13 int main( int argc, char* argv[] )
14 {
15 int a, b;
16 g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING );
17 a = b = 1;
18 do_test( a == b, 'integer equality" );
19 do_test( a != b, 'integer inequality? (should fail)" );
20
21 do_test_args( a == b, "fancy info", __FILE__, __LINE__, "a = %d, b = %b", a, b );
22
23 print_test_results();
24 return get_rv();
25 }
26 */
27 /* If you want to see test passes, use
28 set_success_print(TRUE);
29 before you execute the tests.
30 Otherwise, only failures are printed out.
31 */
32
33
34 #ifndef TEST_STUFF_H
35 #define TEST_STUFF_H
36
37 #include "config.h"
38
39 #include <glib.h>
40 #include <stdlib.h>
41
48 #define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ )
49 #define success( title ) success_call( title, __FILE__, __LINE__ );
50 #define failure( title ) failure_call( title, __FILE__, __LINE__ );
51
58 /* Privately used to indicate a test result. You may use these if you
59 * wish, but it's easier to use the do_test macro above.
60 */
61 gboolean do_test_call (gboolean result,
62 const char *test_title,
63 const char *filename, int line);
64 gboolean do_test_args (gboolean result,
65 const char *test_title,
66 const char *filename,
67 int line, const char *format, ...);
68
69
73 void print_test_results (void);
74
84 void set_success_print (gboolean in_should_print);
85
86 /* Value to return from main. Set to 1 if there were any fails, 0 otherwise. */
87 int get_rv (void);
88
93 void success_call (const char *test_title, const char *file, int line);
94
95 void success_args (const char *test_title,
96 const char *file, int line, const char *format, ...);
97
98 void failure_call (const char *test_title, const char *file, int line);
99
100 void failure_args (const char *test_title,
101 const char *file, int line, const char *format, ...);
102
103 gboolean get_random_boolean (void);
104 gint get_random_int_in_range (int start, int end);
105 void random_character_include_funky_chars (gboolean use_funky_chars);
106 gchar get_random_character (void);
107 gchar *get_random_string (void);
108 gchar *get_random_string_without (const char *exclude_chars);
109 gint64 get_random_gint64 (void);
110 double get_random_double (void);
111 const char *get_random_string_in_array (const char *str_list[]);
112
113 #endif /* TEST_STUFF_H */