QOF
0.7.5
|
00001 /* Modified by bstanley 20010320 00002 * Added do_test macro, do_test_call and do_test_call_args, 00003 * print_test_results, set_success_print. 00004 * 00005 * Modified by bstanley 20010323 00006 * removed testing functionality which depends on the rest of gnucash - 00007 * sepearated into gnc-test-stuff.h 00008 * 00009 */ 00010 00011 /* Outline of a test program using the new testing functions: 00012 #include "test-stuff.h" 00013 int main( int argc, char* argv[] ) 00014 { 00015 int a, b; 00016 g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING ); 00017 a = b = 1; 00018 do_test( a == b, 'integer equality" ); 00019 do_test( a != b, 'integer inequality? (should fail)" ); 00020 00021 do_test_args( a == b, "fancy info", __FILE__, __LINE__, "a = %d, b = %b", a, b ); 00022 00023 print_test_results(); 00024 return get_rv(); 00025 } 00026 */ 00027 /* If you want to see test passes, use 00028 set_success_print(TRUE); 00029 before you execute the tests. 00030 Otherwise, only failures are printed out. 00031 */ 00032 00033 00034 #ifndef TEST_STUFF_H 00035 #define TEST_STUFF_H 00036 00037 #include "config.h" 00038 00039 #include <glib.h> 00040 #include <stdlib.h> 00041 00048 #define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ ) 00049 #define success( title ) success_call( title, __FILE__, __LINE__ ); 00050 #define failure( title ) failure_call( title, __FILE__, __LINE__ ); 00051 00058 /* Privately used to indicate a test result. You may use these if you 00059 * wish, but it's easier to use the do_test macro above. 00060 */ 00061 gboolean do_test_call (gboolean result, 00062 const char *test_title, 00063 const char *filename, int line); 00064 gboolean do_test_args (gboolean result, 00065 const char *test_title, 00066 const char *filename, 00067 int line, const char *format, ...); 00068 00069 00073 void print_test_results (void); 00074 00084 void set_success_print (gboolean in_should_print); 00085 00086 /* Value to return from main. Set to 1 if there were any fails, 0 otherwise. */ 00087 int get_rv (void); 00088 00093 void success_call (const char *test_title, const char *file, int line); 00094 00095 void success_args (const char *test_title, 00096 const char *file, int line, const char *format, ...); 00097 00098 void failure_call (const char *test_title, const char *file, int line); 00099 00100 void failure_args (const char *test_title, 00101 const char *file, int line, const char *format, ...); 00102 00103 gboolean get_random_boolean (void); 00104 gint get_random_int_in_range (int start, int end); 00105 void random_character_include_funky_chars (gboolean use_funky_chars); 00106 gchar get_random_character (void); 00107 gchar *get_random_string (void); 00108 gchar *get_random_string_without (const char *exclude_chars); 00109 gint64 get_random_gint64 (void); 00110 double get_random_double (void); 00111 const char *get_random_string_in_array (const char *str_list[]); 00112 00113 #endif /* TEST_STUFF_H */