GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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  * separated 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 <glib.h>
38 #include <stdlib.h>
39 
46 #define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ )
47 #define success( title ) success_call( title, __FILE__, __LINE__ );
48 #define failure( title ) failure_call( title, __FILE__, __LINE__ );
49 
57 /* Privately used to indicate a test result. You may use these if you
58  * wish, but it's easier to use the do_test macro above.
59  */
60 gboolean do_test_call(
61  gboolean result,
62  const char* test_title,
63  const char* filename,
64  int line );
65 gboolean do_test_args(
66  gboolean result,
67  const char* test_title,
68  const char* filename,
69  int line,
70  const char* format, ... );
71 
72 
76 void print_test_results(void);
77 
87 void set_success_print( gboolean in_should_print );
88 
89 /* Value to return from main. Set to 1 if there were any fails, 0 otherwise. */
90 int get_rv(void);
91 
96 void success_call(
97  const char *test_title,
98  const char *file,
99  int line );
100 
101 void success_args(
102  const char *test_title,
103  const char *file,
104  int line,
105  const char *format,
106  ... );
107 
108 void failure_call(
109  const char *test_title,
110  const char *file,
111  int line);
112 
113 void failure_args(
114  const char *test_title,
115  const char *file,
116  int line,
117  const char *format,
118  ... );
119 
120 gboolean get_random_boolean(void);
121 gint get_random_int_in_range(int start, int end);
122 void random_character_include_funky_chars (gboolean use_funky_chars);
123 gchar get_random_character(void);
124 gchar* get_random_string(void);
125 gchar * get_random_string_length_in_range(int minlen, int maxlen);
126 gchar* get_random_string_without(const char *exclude_chars);
127 gint32 get_random_gint32 (void);
128 gint64 get_random_gint64(void);
129 double get_random_double(void);
130 const char* get_random_string_in_array(const char* str_list[]);
131 
132 
133 #endif /* TEST_STUFF_H */